You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ValidatePasswordTest.php 905B

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