15
15
use Symfony \Component \DependencyInjection \ContainerInterface ;
16
16
use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
17
17
use Symfony \Component \HttpKernel \KernelInterface ;
18
- use Symfony \Contracts \Service \ResetInterface ;
19
18
20
19
/**
21
20
* KernelTestCase is the base class for tests needing a Kernel.
@@ -42,8 +41,6 @@ abstract class KernelTestCase extends TestCase
42
41
43
42
protected static $ booted = false ;
44
43
45
- private static $ kernelContainer ;
46
-
47
44
protected function tearDown (): void
48
45
{
49
46
static ::ensureKernelShutdown ();
@@ -80,11 +77,12 @@ protected static function bootKernel(array $options = [])
80
77
{
81
78
static ::ensureKernelShutdown ();
82
79
83
- static ::$ kernel = static ::createKernel ($ options );
84
- static ::$ kernel ->boot ();
80
+ $ kernel = static ::createKernel ($ options );
81
+ $ kernel ->boot ();
82
+ self ::$ kernel = $ kernel ;
85
83
static ::$ booted = true ;
86
84
87
- self :: $ kernelContainer = $ container = static ::$ kernel ->getContainer ();
85
+ $ container = static ::$ kernel ->getContainer ();
88
86
static ::$ container = $ container ->has ('test.service_container ' ) ? $ container ->get ('test.service_container ' ) : $ container ;
89
87
90
88
return static ::$ kernel ;
@@ -156,14 +154,11 @@ protected static function createKernel(array $options = [])
156
154
protected static function ensureKernelShutdown ()
157
155
{
158
156
if (null !== static ::$ kernel ) {
157
+ static ::$ kernel ->boot ();
159
158
static ::$ kernel ->shutdown ();
160
159
static ::$ booted = false ;
161
160
}
162
161
163
- if (self ::$ kernelContainer instanceof ResetInterface) {
164
- self ::$ kernelContainer ->reset ();
165
- }
166
-
167
- static ::$ container = self ::$ kernelContainer = null ;
162
+ static ::$ container = null ;
168
163
}
169
164
}
0 commit comments