@@ -28,12 +28,12 @@ class TraceableEventDispatcherTest extends TestCase
28
28
public function testStopwatchSections ()
29
29
{
30
30
$ dispatcher = new TraceableEventDispatcher (new EventDispatcher (), $ stopwatch = new Stopwatch ());
31
- $ kernel = $ this ->getHttpKernel ($ dispatcher, function () { return new Response ( '' , 200 , [ ' X-Debug-Token ' => ' 292e1e ' ]); } );
31
+ $ kernel = $ this ->getHttpKernel ($ dispatcher );
32
32
$ request = Request::create ('/ ' );
33
33
$ response = $ kernel ->handle ($ request );
34
34
$ kernel ->terminate ($ request , $ response );
35
35
36
- $ events = $ stopwatch ->getSectionEvents ($ response -> headers ->get ('X-Debug-Token ' ));
36
+ $ events = $ stopwatch ->getSectionEvents ($ request -> attributes ->get ('_stopwatch_token ' ));
37
37
$ this ->assertEquals ([
38
38
'__section__ ' ,
39
39
'kernel.request ' ,
@@ -56,7 +56,7 @@ public function testStopwatchCheckControllerOnRequestEvent()
56
56
57
57
$ dispatcher = new TraceableEventDispatcher (new EventDispatcher (), $ stopwatch );
58
58
59
- $ kernel = $ this ->getHttpKernel ($ dispatcher, function () { return new Response (); } );
59
+ $ kernel = $ this ->getHttpKernel ($ dispatcher );
60
60
$ request = Request::create ('/ ' );
61
61
$ kernel ->handle ($ request );
62
62
}
@@ -69,12 +69,12 @@ public function testStopwatchStopControllerOnRequestEvent()
69
69
$ stopwatch ->expects ($ this ->once ())
70
70
->method ('isStarted ' )
71
71
->willReturn (true );
72
- $ stopwatch ->expects ($ this ->once ( ))
72
+ $ stopwatch ->expects ($ this ->exactly ( 3 ))
73
73
->method ('stop ' );
74
74
75
75
$ dispatcher = new TraceableEventDispatcher (new EventDispatcher (), $ stopwatch );
76
76
77
- $ kernel = $ this ->getHttpKernel ($ dispatcher, function () { return new Response (); } );
77
+ $ kernel = $ this ->getHttpKernel ($ dispatcher );
78
78
$ request = Request::create ('/ ' );
79
79
$ kernel ->handle ($ request );
80
80
}
@@ -110,10 +110,12 @@ public function testListenerCanRemoveItselfWhenExecuted()
110
110
$ this ->assertCount (1 , $ eventDispatcher ->getListeners ('foo ' ), 'expected listener1 to be removed ' );
111
111
}
112
112
113
- protected function getHttpKernel ($ dispatcher, $ controller )
113
+ protected function getHttpKernel ($ dispatcher )
114
114
{
115
115
$ controllerResolver = $ this ->createMock (ControllerResolverInterface::class);
116
- $ controllerResolver ->expects ($ this ->once ())->method ('getController ' )->willReturn ($ controller );
116
+ $ controllerResolver ->expects ($ this ->once ())->method ('getController ' )->willReturn (function () {
117
+ return new Response ();
118
+ });
117
119
$ argumentResolver = $ this ->createMock (ArgumentResolverInterface::class);
118
120
$ argumentResolver ->expects ($ this ->once ())->method ('getArguments ' )->willReturn ([]);
119
121
0 commit comments