Skip to content

Commit 69245ec

Browse files
Merge branch '4.4'
* 4.4: [Validator] Set Length::$allowEmptyString to false when a NotBlank contraint is defined [FrameworkBundle] Dont reset the test container but the real one instead Import missing classes [SecurityBundle] test with doctrine-bundle 2
2 parents 5a2176d + bfce69d commit 69245ec

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CHANGELOG
3030
* Deprecated the `controller_name_converter` and `resolve_controller_name_subscriber` services
3131
* The `ControllerResolver` and `DelegatingLoader` classes have been marked as `final`
3232
* Added support for configuring chained cache pools
33-
* Deprecated booting the kernel before running `WebTestCase::createClient()`
33+
* Deprecated calling `WebTestCase::createClient()` while a kernel has been booted, ensure the kernel is shut down before calling the method
3434
* Deprecated `routing.loader.service`, use `routing.loader.container` instead.
3535
* Not tagging service route loaders with `routing.route_loader` has been deprecated.
3636
* Overriding the methods `KernelTestCase::tearDown()` and `WebTestCase::tearDown()` without the `void` return-type is deprecated.

Test/KernelTestCase.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ abstract class KernelTestCase extends TestCase
3535
*/
3636
protected static $container;
3737

38-
protected static $booted;
38+
protected static $booted = false;
39+
40+
private static $kernelContainer;
3941

4042
protected function tearDown(): void
4143
{
@@ -74,7 +76,7 @@ protected static function bootKernel(array $options = [])
7476
static::$kernel->boot();
7577
static::$booted = true;
7678

77-
$container = static::$kernel->getContainer();
79+
self::$kernelContainer = $container = static::$kernel->getContainer();
7880
static::$container = $container->has('test.service_container') ? $container->get('test.service_container') : $container;
7981

8082
return static::$kernel;
@@ -125,17 +127,14 @@ protected static function createKernel(array $options = [])
125127
protected static function ensureKernelShutdown()
126128
{
127129
if (null !== static::$kernel) {
128-
$isBooted = (new \ReflectionClass(static::$kernel))->getProperty('booted');
129-
$isBooted->setAccessible(true);
130-
if ($isBooted->getValue(static::$kernel)) {
131-
$container = static::$kernel->getContainer();
132-
static::$kernel->shutdown();
133-
static::$booted = false;
134-
if ($container instanceof ResetInterface) {
135-
$container->reset();
136-
}
137-
}
130+
static::$kernel->shutdown();
131+
static::$booted = false;
132+
}
133+
134+
if (self::$kernelContainer instanceof ResetInterface) {
135+
self::$kernelContainer->reset();
138136
}
139-
static::$container = null;
137+
138+
static::$container = self::$kernelContainer = null;
140139
}
141140
}

Test/TestContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function initialized(string $id): bool
117117
*/
118118
public function reset()
119119
{
120-
$this->getPublicContainer()->reset();
120+
// ignore the call
121121
}
122122

123123
/**

Test/WebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function tearDown(): void
4040
*/
4141
protected static function createClient(array $options = [], array $server = [])
4242
{
43-
if (true === static::$booted) {
43+
if (static::$booted) {
4444
throw new \LogicException(sprintf('Booting the kernel before calling %s() is not supported, the kernel should only be booted once.', __METHOD__));
4545
}
4646

Tests/Functional/app/AppKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function getKernelParameters(): array
100100

101101
public function getContainer(): ContainerInterface
102102
{
103-
if (!$this->booted) {
103+
if (!$this->container) {
104104
throw new \LogicException('Cannot access the container on a non-booted kernel. Did you forget to boot it?');
105105
}
106106

0 commit comments

Comments
 (0)