Compare commits

..

2 Commits

Author SHA1 Message Date
Guy Sartorelli
80db2b4c83
Merge 68bc68782dd1e666fb5c26845ac3988581bb7b1a into c523022cb9d52cb8c2567127844f7e16be63cb77 2024-09-24 23:29:55 +00:00
Guy Sartorelli
68bc68782d
ENH Use symfony/validation logic 2024-09-25 11:28:12 +12:00
3 changed files with 10 additions and 10 deletions

View File

@ -211,10 +211,10 @@ class ConfirmedPasswordFieldTest extends SapphireTest
return [ return [
'valid: within min and max' => [3, 8, true], 'valid: within min and max' => [3, 8, true],
'invalid: lower than min with max' => [8, 12, false, 'Passwords must be 8 to 12 characters long'], 'invalid: lower than min with max' => [8, 12, false, 'Passwords must be 8 to 12 characters long'],
'valid: greater than min' => [3, 0, true], 'valid: greater than min' => [3, null, true],
'invalid: lower than min' => [8, 0, false, 'Passwords must be at least 8 characters long'], 'invalid: lower than min' => [8, null, false, 'Passwords must be at least 8 characters long'],
'valid: less than max' => [0, 8, true], 'valid: less than max' => [null, 8, true],
'invalid: greater than max' => [0, 4, false, 'Passwords must be at most 4 characters long'], 'invalid: greater than max' => [null, 4, false, 'Passwords must be at most 4 characters long'],
]; ];
} }
@ -233,7 +233,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest
$this->assertFalse($result, 'Validate method should return its result'); $this->assertFalse($result, 'Validate method should return its result');
$this->assertFalse($validator->getResult()->isValid()); $this->assertFalse($validator->getResult()->isValid());
$this->assertStringContainsString( $this->assertStringContainsString(
'The password strength is too low. Please use a stronger password.', 'Passwords must have at least one digit and one alphanumeric character',
json_encode($validator->getResult()->__serialize()) json_encode($validator->getResult()->__serialize())
); );
} }

View File

@ -1920,12 +1920,12 @@ class MemberTest extends FunctionalTest
$member = new Member(); $member = new Member();
// no password validator // no password validator
Member::set_password_validator(null); Member::set_password_validator(null);
// password length is min 128 chars long // password length is same as length argument
$password = $member->generateRandomPassword(5); $password = $member->generateRandomPassword(5);
$this->assertSame(128, strlen($password)); $this->assertSame(5, strlen($password));
// password length can be longer // default to 20 if not length argument
$password = $member->generateRandomPassword(130); $password = $member->generateRandomPassword();
$this->assertSame(130, strlen($password)); $this->assertSame(20, strlen($password));
// password validator // password validator
$validator = new $validatorClass(); $validator = new $validatorClass();
Member::set_password_validator($validator); Member::set_password_validator($validator);