@@ -40,6 +40,7 @@ public function testValidValues(string|\Stringable $value, int $expectedStrength
40
40
41
41
$ this ->buildViolation ('The password strength is too low. Please use a stronger password. ' )
42
42
->setCode (PasswordStrength::PASSWORD_STRENGTH_ERROR )
43
+ ->setParameter ('{{ strength }} ' , $ expectedStrength )
43
44
->assertRaised ();
44
45
}
45
46
@@ -55,13 +56,15 @@ public static function getValidValues(): iterable
55
56
/**
56
57
* @dataProvider provideInvalidConstraints
57
58
*/
58
- public function testThePasswordIsWeak (PasswordStrength $ constraint , string $ password , string $ expectedMessage , string $ expectedCode , array $ parameters = [] )
59
+ public function testThePasswordIsWeak (PasswordStrength $ constraint , string $ password , string $ expectedMessage , string $ expectedCode , string $ strength )
59
60
{
60
61
$ this ->validator ->validate ($ password , $ constraint );
61
62
62
63
$ this ->buildViolation ($ expectedMessage )
63
64
->setCode ($ expectedCode )
64
- ->setParameters ($ parameters )
65
+ ->setParameters ([
66
+ '{{ strength }} ' => $ strength ,
67
+ ])
65
68
->assertRaised ();
66
69
}
67
70
@@ -72,18 +75,21 @@ public static function provideInvalidConstraints(): iterable
72
75
'password ' ,
73
76
'The password strength is too low. Please use a stronger password. ' ,
74
77
PasswordStrength::PASSWORD_STRENGTH_ERROR ,
78
+ '0 ' ,
75
79
];
76
80
yield [
77
81
new PasswordStrength (minScore: PasswordStrength::STRENGTH_VERY_STRONG ),
78
82
'Good password? ' ,
79
83
'The password strength is too low. Please use a stronger password. ' ,
80
84
PasswordStrength::PASSWORD_STRENGTH_ERROR ,
85
+ '1 ' ,
81
86
];
82
87
yield [
83
88
new PasswordStrength (message: 'This password should be strong. ' ),
84
89
'password ' ,
85
90
'This password should be strong. ' ,
86
91
PasswordStrength::PASSWORD_STRENGTH_ERROR ,
92
+ '0 ' ,
87
93
];
88
94
}
89
95
}
0 commit comments