@@ -49,7 +49,9 @@ public function __construct(KernelInterface $kernel, array $server = [], History
4949 */
5050 public function getContainer ()
5151 {
52- return $ this ->kernel ->getContainer ();
52+ $ container = $ this ->kernel ->getContainer ();
53+
54+ return $ container ->has ('test.service_container ' ) ? $ container ->get ('test.service_container ' ) : $ container ;
5355 }
5456
5557 /**
@@ -69,11 +71,11 @@ public function getKernel()
6971 */
7072 public function getProfile ()
7173 {
72- if (null === $ this ->response || !$ this ->kernel -> getContainer ()->has ('profiler ' )) {
74+ if (null === $ this ->response || !$ this ->getContainer ()->has ('profiler ' )) {
7375 return false ;
7476 }
7577
76- return $ this ->kernel -> getContainer ()->get ('profiler ' )->loadProfileFromResponse ($ this ->response );
78+ return $ this ->getContainer ()->get ('profiler ' )->loadProfileFromResponse ($ this ->response );
7779 }
7880
7981 /**
@@ -83,7 +85,7 @@ public function getProfile()
8385 */
8486 public function enableProfiler ()
8587 {
86- if ($ this ->kernel -> getContainer ()->has ('profiler ' )) {
88+ if ($ this ->getContainer ()->has ('profiler ' )) {
8789 $ this ->profiler = true ;
8890 }
8991 }
@@ -123,7 +125,7 @@ public function loginUser($user, string $firewallContext = 'main'): self
123125 $ token = new TestBrowserToken ($ user ->getRoles (), $ user , $ firewallContext );
124126 $ token ->setAuthenticated (true );
125127
126- $ container = $ this ->kernel -> getContainer ()->get ('test.service_container ' );
128+ $ container = $ this ->getContainer ()->get ('test.service_container ' );
127129 $ container ->get ('security.untracked_token_storage ' )->setToken ($ token );
128130
129131 if (!$ container ->has ('session ' )) {
@@ -161,7 +163,7 @@ protected function doRequest($request)
161163 $ this ->profiler = false ;
162164
163165 $ this ->kernel ->boot ();
164- $ this ->kernel -> getContainer ()->get ('profiler ' )->enable ();
166+ $ this ->getContainer ()->get ('profiler ' )->enable ();
165167 }
166168
167169 return parent ::doRequest ($ request );
@@ -220,7 +222,11 @@ protected function getScript($request)
220222
221223 $ profilerCode = '' ;
222224 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;
224230 }
225231
226232 $ code = <<<EOF
0 commit comments