From a18c510c8dfefd02d6aae82380d17010f93562ca Mon Sep 17 00:00:00 2001 From: core23 Date: Sun, 13 Feb 2022 13:22:48 +0100 Subject: [PATCH] KernelTestCase resets internal state on tearDown --- .../FrameworkBundle/Test/KernelTestCase.php | 1 + .../Functional/TestServiceContainerTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php index 442649ac1bac4..b87018bbd6b3f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php @@ -44,6 +44,7 @@ abstract class KernelTestCase extends TestCase private function doTearDown() { static::ensureKernelShutdown(); + static::$class = null; static::$kernel = null; static::$booted = false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php index bf4f9f8779f44..4122a749dfd1d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/TestServiceContainerTest.php @@ -44,4 +44,22 @@ public function testThatPrivateServicesAreAvailableIfTestConfigIsEnabled() $this->assertTrue(static::$container->has('private_service')); $this->assertFalse(static::$container->has(UnusedPrivateService::class)); } + + /** + * @doesNotPerformAssertions + */ + public function testBootKernel() + { + static::bootKernel(['test_case' => 'TestServiceContainer']); + } + + /** + * @depends testBootKernel + */ + public function testKernelIsNotInitialized() + { + self::assertNull(self::$class); + self::assertNull(self::$kernel); + self::assertFalse(self::$booted); + } }