44namespace Zalas \Injector \PHPUnit \Tests \Symfony \TestCase ;
55
66use PHPUnit \Framework \TestCase ;
7+ use Symfony \Component \HttpKernel \Kernel ;
78use Symfony \Component \HttpKernel \KernelInterface ;
89use Zalas \Injector \PHPUnit \Symfony \TestCase \SymfonyKernel ;
910use Zalas \Injector \PHPUnit \Tests \Symfony \TestCase \Fixtures \NoFrameworkBundle \TestKernel ;
@@ -117,8 +118,11 @@ public function test_it_prefers_env_variables_over_server()
117118 /**
118119 * @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
119120 */
120- public function test_it_ensures_the_kernel_was_shut_down ()
121+ public function test_it_ensures_the_kernel_was_shut_down_on_legacy_symfony_versions ()
121122 {
123+ if (Kernel::MAJOR_VERSION > 4 ) {
124+ $ this ->markTestSkipped ();
125+ }
122126 $ kernel1 = self ::bootKernel ();
123127 $ kernel2 = self ::bootKernel ();
124128
@@ -129,15 +133,55 @@ public function test_it_ensures_the_kernel_was_shut_down()
129133 /**
130134 * @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
131135 */
132- public function test_ensureKernelShutdown_shuts_down_the_kernel ()
136+ public function test_ensureKernelShutdown_shuts_down_the_kernel_on_legacy_symfony_versions ()
133137 {
138+ if (Kernel::MAJOR_VERSION > 4 ) {
139+ $ this ->markTestSkipped ();
140+ }
134141 $ kernel = self ::bootKernel ();
135142
136143 self ::ensureKernelShutdown ();
137144
138145 $ this ->assertNull ($ kernel ->getContainer ());
139146 }
140147
148+ /**
149+ * @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
150+ */
151+ public function test_it_ensures_the_kernel_was_shut_down ()
152+ {
153+ if (Kernel::MAJOR_VERSION < 5 ) {
154+ $ this ->markTestSkipped ();
155+ }
156+ $ this ->expectException (\LogicException::class);
157+ $ this ->expectExceptionMessageMatches ('/Cannot retrieve the container from a non-booted kernel/ ' );
158+
159+ $ kernel1 = self ::bootKernel ();
160+ $ kernel2 = self ::bootKernel ();
161+
162+ $ this ->assertNotNull ($ kernel2 ->getContainer ());
163+
164+ $ kernel1 ->getContainer ();
165+ }
166+
167+ /**
168+ * @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
169+ */
170+ public function test_ensureKernelShutdown_shuts_down_the_kernel ()
171+ {
172+ if (Kernel::MAJOR_VERSION < 5 ) {
173+ $ this ->markTestSkipped ();
174+ }
175+ $ this ->expectException (\LogicException::class);
176+ $ this ->expectExceptionMessageMatches ('/Cannot retrieve the container from a non-booted kernel/ ' );
177+
178+ $ kernel = self ::bootKernel ();
179+
180+ self ::ensureKernelShutdown ();
181+
182+ $ kernel ->getContainer ();
183+ }
184+
141185 /**
142186 * @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
143187 */
0 commit comments