4
4
namespace Zalas \Injector \PHPUnit \Tests \Symfony \TestCase ;
5
5
6
6
use PHPUnit \Framework \TestCase ;
7
+ use Symfony \Component \HttpKernel \Kernel ;
7
8
use Symfony \Component \HttpKernel \KernelInterface ;
8
9
use Zalas \Injector \PHPUnit \Symfony \TestCase \SymfonyKernel ;
9
10
use Zalas \Injector \PHPUnit \Tests \Symfony \TestCase \Fixtures \NoFrameworkBundle \TestKernel ;
@@ -117,8 +118,11 @@ public function test_it_prefers_env_variables_over_server()
117
118
/**
118
119
* @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
119
120
*/
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 ()
121
122
{
123
+ if (Kernel::MAJOR_VERSION > 4 ) {
124
+ $ this ->markTestSkipped ();
125
+ }
122
126
$ kernel1 = self ::bootKernel ();
123
127
$ kernel2 = self ::bootKernel ();
124
128
@@ -129,15 +133,55 @@ public function test_it_ensures_the_kernel_was_shut_down()
129
133
/**
130
134
* @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
131
135
*/
132
- public function test_ensureKernelShutdown_shuts_down_the_kernel ()
136
+ public function test_ensureKernelShutdown_shuts_down_the_kernel_on_legacy_symfony_versions ()
133
137
{
138
+ if (Kernel::MAJOR_VERSION > 4 ) {
139
+ $ this ->markTestSkipped ();
140
+ }
134
141
$ kernel = self ::bootKernel ();
135
142
136
143
self ::ensureKernelShutdown ();
137
144
138
145
$ this ->assertNull ($ kernel ->getContainer ());
139
146
}
140
147
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
+
141
185
/**
142
186
* @env KERNEL_CLASS=Zalas\Injector\PHPUnit\Tests\Symfony\TestCase\Fixtures\NoFrameworkBundle\TestKernel
143
187
*/
0 commit comments