Hackzilla\PasswordGenerator\Generator\PasswordGeneratorInterface::setOptionValue PHP Method

setOptionValue() public method

public setOptionValue ( $option, $value )
    public function setOptionValue($option, $value);

Usage Example

 /**
  * @dataProvider passwordsProvider
  *
  * @param string $vowels
  * @param bool   $upperCase
  * @param bool   $symbols
  * @param bool   $numbers
  */
 public function testGeneratePassword($vowels, $upperCase, $symbols, $numbers)
 {
     $this->_object->setParameter(PronounceablePasswordGenerator::PARAMETER_VOWELS, $vowels);
     $this->_object->setOptionValue(ComputerPasswordGenerator::OPTION_LENGTH, 16);
     $this->_object->setOptionValue(ComputerPasswordGenerator::OPTION_LOWER_CASE, true);
     $this->_object->setOptionValue(ComputerPasswordGenerator::OPTION_UPPER_CASE, $upperCase);
     $this->_object->setOptionValue(ComputerPasswordGenerator::OPTION_SYMBOLS, $symbols);
     $this->_object->setOptionValue(ComputerPasswordGenerator::OPTION_NUMBERS, $numbers);
     $passwords = $this->_object->generatePasswords(10);
     foreach ($passwords as $password) {
         $passwordLen = strlen($password);
         $isLastCharVowel = null;
         for ($i = 0; $i < $passwordLen; $i++) {
             $char = $password[$i];
             $isVowel = false !== stripos($vowels, $char);
             if (null !== $isLastCharVowel) {
                 $this->assertNotEquals($isVowel, $isLastCharVowel);
             }
             $isLastCharVowel = $isVowel;
         }
     }
 }