@@ -45,7 +45,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage()
4545 ->method ('setToken ' )
4646 ;
4747
48- $ this ->assertNull ($ listener ($ this ->getGetResponseEvent ( )));
48+ $ this ->assertNull ($ listener (new RequestEvent ( $ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface:: MASTER_REQUEST )));
4949 }
5050
5151 public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet ()
@@ -64,9 +64,7 @@ public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet()
6464 ->willReturn (null )
6565 ;
6666
67- $ event = $ this ->getGetResponseEvent ();
68-
69- $ this ->assertNull ($ listener ($ event ));
67+ $ this ->assertNull ($ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST )));
7068 }
7169
7270 public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenticationManagerImplementation ()
@@ -99,9 +97,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti
9997 ->willThrowException ($ exception )
10098 ;
10199
102- $ event = $ this ->getGetResponseEvent ($ request );
103-
104- $ listener ($ event );
100+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
105101 }
106102
107103 public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation ()
@@ -134,9 +130,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti
134130 ->willThrowException ($ exception )
135131 ;
136132
137- $ event = $ this ->getGetResponseEvent ();
138-
139- $ listener ($ event );
133+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
140134 }
141135
142136 public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggersLoginFail ()
@@ -166,9 +160,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers
166160 ->method ('authenticate ' )
167161 ;
168162
169- $ event = $ this ->getGetResponseEvent ();
170-
171- $ listener ($ event );
163+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
172164 }
173165
174166 public function testOnCoreSecurity ()
@@ -200,9 +192,7 @@ public function testOnCoreSecurity()
200192 ->willReturn ($ token )
201193 ;
202194
203- $ event = $ this ->getGetResponseEvent ();
204-
205- $ listener ($ event );
195+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
206196 }
207197
208198 public function testSessionStrategy ()
@@ -244,15 +234,13 @@ public function testSessionStrategy()
244234 $ request = new Request ();
245235 $ request ->setSession ($ session );
246236
247- $ event = $ this ->getGetResponseEvent ($ request );
248-
249237 $ sessionStrategy
250238 ->expects ($ this ->once ())
251239 ->method ('onAuthentication ' )
252240 ->willReturn (null )
253241 ;
254242
255- $ listener ($ event );
243+ $ listener (new RequestEvent ( $ this -> createMock (HttpKernelInterface::class), $ request , HttpKernelInterface:: MASTER_REQUEST ) );
256244 }
257245
258246 public function testSessionIsMigratedByDefault ()
@@ -298,9 +286,7 @@ public function testSessionIsMigratedByDefault()
298286 $ request = new Request ();
299287 $ request ->setSession ($ session );
300288
301- $ event = $ this ->getGetResponseEvent ($ request );
302-
303- $ listener ($ event );
289+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
304290 }
305291
306292 public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherIsPresent ()
@@ -332,8 +318,6 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
332318 ->willReturn ($ token )
333319 ;
334320
335- $ event = $ this ->getGetResponseEvent ();
336-
337321 $ dispatcher
338322 ->expects ($ this ->once ())
339323 ->method ('dispatch ' )
@@ -343,23 +327,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
343327 )
344328 ;
345329
346- $ listener ($ event );
347- }
348-
349- protected function getGetResponseEvent (Request $ request = null ): RequestEvent
350- {
351- $ request = $ request ?? new Request ();
352-
353- $ event = $ this ->getMockBuilder (RequestEvent::class)
354- ->setConstructorArgs ([$ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ])
355- ->getMock ();
356- $ event
357- ->expects ($ this ->any ())
358- ->method ('getRequest ' )
359- ->willReturn ($ request )
360- ;
361-
362- return $ event ;
330+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
363331 }
364332
365333 protected function getListener ($ withDispatcher = false , $ catchExceptions = true , $ withSessionStrategy = false )
0 commit comments