@@ -101,7 +101,7 @@ public function testAuthenticateRequest($matchingAuthenticatorIndex)
101
101
102
102
$ authenticators [($ matchingAuthenticatorIndex + 1 ) % 2 ]->expects ($ this ->never ())->method ('authenticate ' );
103
103
104
- $ matchingAuthenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , function () { return $ this ->user ; } )));
104
+ $ matchingAuthenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , fn () => $ this ->user )));
105
105
106
106
$ listenerCalled = false ;
107
107
$ this ->eventDispatcher ->addListener (CheckPassportEvent::class, function (CheckPassportEvent $ event ) use (&$ listenerCalled , $ matchingAuthenticator ) {
@@ -129,7 +129,7 @@ public function testNoCredentialsValidated()
129
129
$ authenticator = $ this ->createAuthenticator ();
130
130
$ this ->request ->attributes ->set ('_security_authenticators ' , [$ authenticator ]);
131
131
132
- $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new Passport (new UserBadge ('wouter ' , function () { return $ this ->user ; } ), new PasswordCredentials ('pass ' )));
132
+ $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new Passport (new UserBadge ('wouter ' , fn () => $ this ->user ), new PasswordCredentials ('pass ' )));
133
133
134
134
$ authenticator ->expects ($ this ->once ())
135
135
->method ('onAuthenticationFailure ' )
@@ -146,9 +146,7 @@ public function testRequiredBadgeMissing()
146
146
147
147
$ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' )));
148
148
149
- $ authenticator ->expects ($ this ->once ())->method ('onAuthenticationFailure ' )->with ($ this ->anything (), $ this ->callback (function ($ exception ) {
150
- return 'Authentication failed; Some badges marked as required by the firewall config are not available on the passport: " ' .CsrfTokenBadge::class.'". ' === $ exception ->getMessage ();
151
- }));
149
+ $ authenticator ->expects ($ this ->once ())->method ('onAuthenticationFailure ' )->with ($ this ->anything (), $ this ->callback (fn ($ exception ) => 'Authentication failed; Some badges marked as required by the firewall config are not available on the passport: " ' .CsrfTokenBadge::class.'". ' === $ exception ->getMessage ()));
152
150
153
151
$ manager = $ this ->createManager ([$ authenticator ], 'main ' , true , [CsrfTokenBadge::class]);
154
152
$ manager ->authenticateRequest ($ this ->request );
@@ -178,7 +176,7 @@ public function testEraseCredentials($eraseCredentials)
178
176
$ authenticator = $ this ->createAuthenticator ();
179
177
$ this ->request ->attributes ->set ('_security_authenticators ' , [$ authenticator ]);
180
178
181
- $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , function () { return $ this ->user ; } )));
179
+ $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , fn () => $ this ->user )));
182
180
183
181
$ authenticator ->expects ($ this ->any ())->method ('createToken ' )->willReturn ($ this ->token );
184
182
@@ -199,7 +197,7 @@ public function testAuthenticateRequestCanModifyTokenFromEvent()
199
197
$ authenticator = $ this ->createAuthenticator ();
200
198
$ this ->request ->attributes ->set ('_security_authenticators ' , [$ authenticator ]);
201
199
202
- $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , function () { return $ this ->user ; } )));
200
+ $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , fn () => $ this ->user )));
203
201
204
202
$ authenticator ->expects ($ this ->any ())->method ('createToken ' )->willReturn ($ this ->token );
205
203
@@ -257,7 +255,7 @@ public function testInteractiveAuthenticator()
257
255
$ authenticator ->expects ($ this ->any ())->method ('isInteractive ' )->willReturn (true );
258
256
$ this ->request ->attributes ->set ('_security_authenticators ' , [$ authenticator ]);
259
257
260
- $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , function () { return $ this ->user ; } )));
258
+ $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , fn () => $ this ->user )));
261
259
$ authenticator ->expects ($ this ->any ())->method ('createToken ' )->willReturn ($ this ->token );
262
260
263
261
$ this ->tokenStorage ->expects ($ this ->once ())->method ('setToken ' )->with ($ this ->token );
@@ -278,7 +276,7 @@ public function testLegacyInteractiveAuthenticator()
278
276
$ authenticator ->expects ($ this ->any ())->method ('isInteractive ' )->willReturn (true );
279
277
$ this ->request ->attributes ->set ('_security_authenticators ' , [$ authenticator ]);
280
278
281
- $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , function () { return $ this ->user ; } )));
279
+ $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , fn () => $ this ->user )));
282
280
$ authenticator ->expects ($ this ->any ())->method ('createToken ' )->willReturn ($ this ->token );
283
281
284
282
$ this ->tokenStorage ->expects ($ this ->once ())->method ('setToken ' )->with ($ this ->token );
@@ -303,9 +301,7 @@ public function testAuthenticateRequestHidesInvalidUserExceptions()
303
301
304
302
$ authenticator ->expects ($ this ->any ())
305
303
->method ('onAuthenticationFailure ' )
306
- ->with ($ this ->equalTo ($ this ->request ), $ this ->callback (function ($ e ) use ($ invalidUserException ) {
307
- return $ e instanceof BadCredentialsException && $ invalidUserException === $ e ->getPrevious ();
308
- }))
304
+ ->with ($ this ->equalTo ($ this ->request ), $ this ->callback (fn ($ e ) => $ e instanceof BadCredentialsException && $ invalidUserException === $ e ->getPrevious ()))
309
305
->willReturn ($ this ->response );
310
306
311
307
$ manager = $ this ->createManager ([$ authenticator ]);
@@ -319,7 +315,7 @@ public function testLogsUseTheDecoratedAuthenticatorWhenItIsTraceable()
319
315
$ authenticator ->expects ($ this ->any ())->method ('isInteractive ' )->willReturn (true );
320
316
$ this ->request ->attributes ->set ('_security_authenticators ' , [new TraceableAuthenticator ($ authenticator )]);
321
317
322
- $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , function () { return $ this ->user ; } )));
318
+ $ authenticator ->expects ($ this ->any ())->method ('authenticate ' )->willReturn (new SelfValidatingPassport (new UserBadge ('wouter ' , fn () => $ this ->user )));
323
319
$ authenticator ->expects ($ this ->any ())->method ('createToken ' )->willReturn ($ this ->token );
324
320
325
321
$ this ->tokenStorage ->expects ($ this ->once ())->method ('setToken ' )->with ($ this ->token );
0 commit comments