ValidatePasswordTest.php 877 B

1234567891011121314151617181920
  1. <?php
  2. class ValidatePasswordTest extends \PHPUnit\Framework\TestCase {
  3. public function testBasic() {
  4. $config = Config::getInstance();
  5. // Set to the defaults, just to make sure.
  6. Config::write('password_validation', array(
  7. # '/regular expression/' => '$PALANG key (optional: + parameter)',
  8. '/.{5}/' => 'password_too_short 5', # minimum length 5 characters
  9. '/([a-zA-Z].*){3}/' => 'password_no_characters 3', # must contain at least 3 characters
  10. '/([0-9].*){2}/' => 'password_no_digits 2', # must contain at least 2 digits
  11. ));
  12. $this->assertEmpty(validate_password('fishSheep01'));
  13. $this->assertEmpty(validate_password('Password01'));
  14. $this->assertNotEmpty(validate_password('pas')); // notEmpty == fail
  15. $this->assertNotEmpty(validate_password('pa1'));
  16. }
  17. }