@@ -30,8 +30,7 @@ protected function setUp(): void
3030 {
3131 parent ::setUp ();
3232
33- $ config = new Auth ();
34- $ this ->validator = new NothingPersonalValidator ($ config );
33+ $ this ->validator = new NothingPersonalValidator (new Auth ());
3534 }
3635
3736 public function testFalseOnPasswordIsEmail (): void
@@ -86,11 +85,8 @@ public function testTrueWhenPasswordHasNothingPersonal(): void
8685 {
8786 $ config = new Auth ();
8887 $ config ->maxSimilarity = 50 ;
89- $ config ->personalFields = [
90- 'firstname ' ,
91- 'lastname ' ,
92- ];
93- $ this ->validator = new NothingPersonalValidator ($ config );
88+ $ config ->personalFields = ['firstname ' , 'lastname ' ];
89+ $ this ->validator = new NothingPersonalValidator ($ config );
9490
9591 $ user = new User ([
9692 'email ' => 'jsmith@example.com ' ,
@@ -110,11 +106,8 @@ public function testTrueWhenNoUsername(): void
110106 {
111107 $ config = new Auth ();
112108 $ config ->maxSimilarity = 50 ;
113- $ config ->personalFields = [
114- 'firstname ' ,
115- 'lastname ' ,
116- ];
117- $ this ->validator = new NothingPersonalValidator ($ config );
109+ $ config ->personalFields = ['firstname ' , 'lastname ' ];
110+ $ this ->validator = new NothingPersonalValidator ($ config );
118111
119112 $ user = new User ([
120113 'email ' => 'jsmith@example.com ' ,
@@ -169,9 +162,9 @@ public function testFalseForSensibleMatch(): void
169162 * $config->maxSimilarity = 50; is the highest setting where all tests pass.
170163 */
171164 #[DataProvider('provideIsNotPersonalFalsePositivesCaughtByIsNotSimilar ' )]
172- public function testIsNotPersonalFalsePositivesCaughtByIsNotSimilar (mixed $ password ): void
165+ public function testIsNotPersonalFalsePositivesCaughtByIsNotSimilar (string $ password ): void
173166 {
174- new User ([
167+ $ user = new User ([
175168 'username ' => 'CaptainJoe ' ,
176169 'email ' => 'JosephSmith@example.com ' ,
177170 ]);
@@ -180,16 +173,19 @@ public function testIsNotPersonalFalsePositivesCaughtByIsNotSimilar(mixed $passw
180173 $ config ->maxSimilarity = 50 ;
181174 $ this ->validator = new NothingPersonalValidator ($ config );
182175
183- $ isNotPersonal = $ this -> getPrivateMethodInvoker ($ this ->validator , 'isNotPersonal ' );
176+ $ isNotPersonal = self :: getPrivateMethodInvoker ($ this ->validator , 'isNotPersonal ' );
184177
185- $ isNotSimilar = $ this -> getPrivateMethodInvoker ($ this ->validator , 'isNotSimilar ' );
178+ $ isNotSimilar = self :: getPrivateMethodInvoker ($ this ->validator , 'isNotSimilar ' );
186179
187- $ this ->assertNotSame ($ isNotPersonal , $ isNotSimilar );
180+ $ this ->assertNotSame ($ isNotPersonal( $ password , $ user ), $ isNotSimilar( $ password , $ user ) );
188181 }
189182
183+ /**
184+ * @return iterable<int, array{0: string}>
185+ */
190186 public static function provideIsNotPersonalFalsePositivesCaughtByIsNotSimilar (): iterable
191187 {
192- return [
188+ yield from [
193189 ['JoeTheCaptain ' ],
194190 ['JoeCaptain ' ],
195191 ['CaptainJ ' ],
@@ -202,15 +198,12 @@ public static function provideIsNotPersonalFalsePositivesCaughtByIsNotSimilar():
202198 }
203199
204200 #[DataProvider('provideConfigPersonalFieldsValues ' )]
205- public function testConfigPersonalFieldsValues (mixed $ firstName , mixed $ lastName , mixed $ expected ): void
201+ public function testConfigPersonalFieldsValues (string $ firstName , string $ lastName , bool $ expected ): void
206202 {
207203 $ config = new Auth ();
208204 $ config ->maxSimilarity = 66 ;
209- $ config ->personalFields = [
210- 'firstname ' ,
211- 'lastname ' ,
212- ];
213- $ this ->validator = new NothingPersonalValidator ($ config );
205+ $ config ->personalFields = ['firstname ' , 'lastname ' ];
206+ $ this ->validator = new NothingPersonalValidator ($ config );
214207
215208 $ user = new User ([
216209 'username ' => 'Vlad the Impaler ' ,
@@ -226,9 +219,12 @@ public function testConfigPersonalFieldsValues(mixed $firstName, mixed $lastName
226219 $ this ->assertSame ($ expected , $ result ->isOK ());
227220 }
228221
222+ /**
223+ * @return iterable<int, array{0: string, 1: string, 2: bool}>
224+ */
229225 public static function provideConfigPersonalFieldsValues (): iterable
230226 {
231- return [
227+ yield from [
232228 [
233229 'Count ' ,
234230 '' ,
@@ -248,7 +244,7 @@ public static function provideConfigPersonalFieldsValues(): iterable
248244 }
249245
250246 #[DataProvider('provideMaxSimilarityZeroTurnsOffSimilarityCalculation ' )]
251- public function testMaxSimilarityZeroTurnsOffSimilarityCalculation (mixed $ maxSimilarity , mixed $ expected ): void
247+ public function testMaxSimilarityZeroTurnsOffSimilarityCalculation (int $ maxSimilarity , bool $ expected ): void
252248 {
253249 $ config = new Auth ();
254250 $ config ->maxSimilarity = $ maxSimilarity ;
@@ -266,6 +262,9 @@ public function testMaxSimilarityZeroTurnsOffSimilarityCalculation(mixed $maxSim
266262 $ this ->assertSame ($ expected , $ result ->isOK ());
267263 }
268264
265+ /**
266+ * @return iterable<int, array{0: int, 1: bool}>
267+ */
269268 public static function provideMaxSimilarityZeroTurnsOffSimilarityCalculation (): iterable
270269 {
271270 return [
@@ -298,6 +297,9 @@ public function testCheckPasswordWithBadEmail(string $email, bool $expected): vo
298297 $ this ->assertSame ($ expected , $ result ->isOK ());
299298 }
300299
300+ /**
301+ * @return iterable<int, array{0: string, 1: bool}>
302+ */
301303 public static function provideCheckPasswordWithBadEmail (): iterable
302304 {
303305 return [
0 commit comments