@@ -49,7 +49,9 @@ public function __construct(KernelInterface $kernel, array $server = [], History
49
49
*/
50
50
public function getContainer ()
51
51
{
52
- return $ this ->kernel ->getContainer ();
52
+ $ container = $ this ->kernel ->getContainer ();
53
+
54
+ return $ container ->has ('test.service_container ' ) ? $ container ->get ('test.service_container ' ) : $ container ;
53
55
}
54
56
55
57
/**
@@ -69,11 +71,11 @@ public function getKernel()
69
71
*/
70
72
public function getProfile ()
71
73
{
72
- if (null === $ this ->response || !$ this ->kernel -> getContainer ()->has ('profiler ' )) {
74
+ if (null === $ this ->response || !$ this ->getContainer ()->has ('profiler ' )) {
73
75
return false ;
74
76
}
75
77
76
- return $ this ->kernel -> getContainer ()->get ('profiler ' )->loadProfileFromResponse ($ this ->response );
78
+ return $ this ->getContainer ()->get ('profiler ' )->loadProfileFromResponse ($ this ->response );
77
79
}
78
80
79
81
/**
@@ -83,7 +85,7 @@ public function getProfile()
83
85
*/
84
86
public function enableProfiler ()
85
87
{
86
- if ($ this ->kernel -> getContainer ()->has ('profiler ' )) {
88
+ if ($ this ->getContainer ()->has ('profiler ' )) {
87
89
$ this ->profiler = true ;
88
90
}
89
91
}
@@ -123,7 +125,7 @@ public function loginUser($user, string $firewallContext = 'main'): self
123
125
$ token = new TestBrowserToken ($ user ->getRoles (), $ user , $ firewallContext );
124
126
$ token ->setAuthenticated (true );
125
127
126
- $ container = $ this ->kernel -> getContainer ()->get ('test.service_container ' );
128
+ $ container = $ this ->getContainer ()->get ('test.service_container ' );
127
129
$ container ->get ('security.untracked_token_storage ' )->setToken ($ token );
128
130
129
131
if (!$ container ->has ('session ' )) {
@@ -161,7 +163,7 @@ protected function doRequest($request)
161
163
$ this ->profiler = false ;
162
164
163
165
$ this ->kernel ->boot ();
164
- $ this ->kernel -> getContainer ()->get ('profiler ' )->enable ();
166
+ $ this ->getContainer ()->get ('profiler ' )->enable ();
165
167
}
166
168
167
169
return parent ::doRequest ($ request );
@@ -220,7 +222,11 @@ protected function getScript($request)
220
222
221
223
$ profilerCode = '' ;
222
224
if ($ this ->profiler ) {
223
- $ profilerCode = '$kernel->getContainer()->get( \'profiler \')->enable(); ' ;
225
+ $ profilerCode = <<<'EOF'
226
+ $container = $kernel->getContainer();
227
+ $container = $container->has('test.service_container') ? $container->get('test.service_container') : $container;
228
+ $container->get('profiler')->enable();
229
+ EOF;
224
230
}
225
231
226
232
$ code = <<<EOF
0 commit comments