1515use Symfony \Component \DependencyInjection \ContainerInterface ;
1616use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
1717use Symfony \Component \HttpKernel \KernelInterface ;
18- use Symfony \Contracts \Service \ResetInterface ;
1918
2019/**
2120 * KernelTestCase is the base class for tests needing a Kernel.
@@ -42,8 +41,6 @@ abstract class KernelTestCase extends TestCase
4241
4342 protected static $ booted = false ;
4443
45- private static $ kernelContainer ;
46-
4744 protected function tearDown (): void
4845 {
4946 static ::ensureKernelShutdown ();
@@ -80,11 +77,12 @@ protected static function bootKernel(array $options = [])
8077 {
8178 static ::ensureKernelShutdown ();
8279
83- static ::$ kernel = static ::createKernel ($ options );
84- static ::$ kernel ->boot ();
80+ $ kernel = static ::createKernel ($ options );
81+ $ kernel ->boot ();
82+ self ::$ kernel = $ kernel ;
8583 static ::$ booted = true ;
8684
87- self :: $ kernelContainer = $ container = static ::$ kernel ->getContainer ();
85+ $ container = static ::$ kernel ->getContainer ();
8886 static ::$ container = $ container ->has ('test.service_container ' ) ? $ container ->get ('test.service_container ' ) : $ container ;
8987
9088 return static ::$ kernel ;
@@ -156,14 +154,11 @@ protected static function createKernel(array $options = [])
156154 protected static function ensureKernelShutdown ()
157155 {
158156 if (null !== static ::$ kernel ) {
157+ static ::$ kernel ->boot ();
159158 static ::$ kernel ->shutdown ();
160159 static ::$ booted = false ;
161160 }
162161
163- if (self ::$ kernelContainer instanceof ResetInterface) {
164- self ::$ kernelContainer ->reset ();
165- }
166-
167- static ::$ container = self ::$ kernelContainer = null ;
162+ static ::$ container = null ;
168163 }
169164}
0 commit comments