@@ -48,7 +48,7 @@ public function testOnCoreSecurityDoesNotTryToPopulateNonEmptyTokenStorage()
48
48
->method ('setToken ' )
49
49
;
50
50
51
- $ this ->assertNull ($ listener ($ this ->getRequestEvent ( )));
51
+ $ this ->assertNull ($ listener (new RequestEvent ( $ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface:: MASTER_REQUEST )));
52
52
}
53
53
54
54
public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet ()
@@ -67,9 +67,7 @@ public function testOnCoreSecurityDoesNothingWhenNoCookieIsSet()
67
67
->willReturn (null )
68
68
;
69
69
70
- $ event = $ this ->getRequestEvent ();
71
-
72
- $ this ->assertNull ($ listener ($ event ));
70
+ $ this ->assertNull ($ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST )));
73
71
}
74
72
75
73
public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenticationManagerImplementation ()
@@ -102,9 +100,7 @@ public function testOnCoreSecurityIgnoresAuthenticationExceptionThrownByAuthenti
102
100
->willThrowException ($ exception )
103
101
;
104
102
105
- $ event = $ this ->getRequestEvent ($ request );
106
-
107
- $ listener ($ event );
103
+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
108
104
}
109
105
110
106
public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation ()
@@ -137,9 +133,7 @@ public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExcepti
137
133
->willThrowException ($ exception )
138
134
;
139
135
140
- $ event = $ this ->getRequestEvent ();
141
-
142
- $ listener ($ event );
136
+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
143
137
}
144
138
145
139
public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggersLoginFail ()
@@ -169,9 +163,7 @@ public function testOnCoreSecurityAuthenticationExceptionDuringAutoLoginTriggers
169
163
->method ('authenticate ' )
170
164
;
171
165
172
- $ event = $ this ->getRequestEvent ();
173
-
174
- $ listener ($ event );
166
+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
175
167
}
176
168
177
169
public function testOnCoreSecurity ()
@@ -203,9 +195,7 @@ public function testOnCoreSecurity()
203
195
->willReturn ($ token )
204
196
;
205
197
206
- $ event = $ this ->getRequestEvent ();
207
-
208
- $ listener ($ event );
198
+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MASTER_REQUEST ));
209
199
}
210
200
211
201
public function testSessionStrategy ()
@@ -247,15 +237,13 @@ public function testSessionStrategy()
247
237
$ request = new Request ();
248
238
$ request ->setSession ($ session );
249
239
250
- $ event = $ this ->getRequestEvent ($ request );
251
-
252
240
$ sessionStrategy
253
241
->expects ($ this ->once ())
254
242
->method ('onAuthentication ' )
255
243
->willReturn (null )
256
244
;
257
245
258
- $ listener ($ event );
246
+ $ listener (new RequestEvent ( $ this -> createMock (HttpKernelInterface::class), $ request , HttpKernelInterface:: MASTER_REQUEST ) );
259
247
}
260
248
261
249
public function testSessionIsMigratedByDefault ()
@@ -301,9 +289,7 @@ public function testSessionIsMigratedByDefault()
301
289
$ request = new Request ();
302
290
$ request ->setSession ($ session );
303
291
304
- $ event = $ this ->getRequestEvent ($ request );
305
-
306
- $ listener ($ event );
292
+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MASTER_REQUEST ));
307
293
}
308
294
309
295
public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherIsPresent ()
@@ -335,8 +321,6 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
335
321
->willReturn ($ token )
336
322
;
337
323
338
- $ event = $ this ->getRequestEvent ();
339
-
340
324
$ dispatcher
341
325
->expects ($ this ->once ())
342
326
->method ('dispatch ' )
@@ -346,23 +330,7 @@ public function testOnCoreSecurityInteractiveLoginEventIsDispatchedIfDispatcherI
346
330
)
347
331
;
348
332
349
- $ listener ($ event );
350
- }
351
-
352
- protected function getRequestEvent (Request $ request = null ): RequestEvent
353
- {
354
- $ request = $ request ?? new Request ();
355
-
356
- $ event = $ this ->getMockBuilder (RequestEvent::class)
357
- ->setConstructorArgs ([$ this ->createMock (HttpKernelInterface::class), $ request , HttpKernelInterface::MAIN_REQUEST ])
358
- ->getMock ();
359
- $ event
360
- ->expects ($ this ->any ())
361
- ->method ('getRequest ' )
362
- ->willReturn ($ request )
363
- ;
364
-
365
- return $ event ;
333
+ $ listener (new RequestEvent ($ this ->createMock (HttpKernelInterface::class), new Request (), HttpKernelInterface::MAIN_REQUEST ));
366
334
}
367
335
368
336
protected function getListener ($ withDispatcher = false , $ catchExceptions = true , $ withSessionStrategy = false )
0 commit comments