1414use PHPUnit \Framework \TestCase ;
1515use Symfony \Component \DependencyInjection \ContainerInterface ;
1616use Symfony \Component \HttpKernel \KernelInterface ;
17- use Symfony \Contracts \Service \ResetInterface ;
1817
1918/**
2019 * KernelTestCase is the base class for tests needing a Kernel.
@@ -39,8 +38,6 @@ abstract class KernelTestCase extends TestCase
3938
4039 protected static $ booted = false ;
4140
42- private static $ kernelContainer ;
43-
4441 private function doTearDown ()
4542 {
4643 static ::ensureKernelShutdown ();
@@ -77,11 +74,12 @@ protected static function bootKernel(array $options = [])
7774 {
7875 static ::ensureKernelShutdown ();
7976
80- static ::$ kernel = static ::createKernel ($ options );
81- static ::$ kernel ->boot ();
77+ $ kernel = static ::createKernel ($ options );
78+ $ kernel ->boot ();
79+ self ::$ kernel = $ kernel ;
8280 static ::$ booted = true ;
8381
84- self :: $ kernelContainer = $ container = static ::$ kernel ->getContainer ();
82+ $ container = static ::$ kernel ->getContainer ();
8583 static ::$ container = $ container ->has ('test.service_container ' ) ? $ container ->get ('test.service_container ' ) : $ container ;
8684
8785 return static ::$ kernel ;
@@ -132,14 +130,11 @@ protected static function createKernel(array $options = [])
132130 protected static function ensureKernelShutdown ()
133131 {
134132 if (null !== static ::$ kernel ) {
133+ static ::$ kernel ->boot ();
135134 static ::$ kernel ->shutdown ();
136135 static ::$ booted = false ;
137136 }
138137
139- if (self ::$ kernelContainer instanceof ResetInterface) {
140- self ::$ kernelContainer ->reset ();
141- }
142-
143- static ::$ container = self ::$ kernelContainer = null ;
138+ static ::$ container = null ;
144139 }
145140}
0 commit comments