diff --git a/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/SetUpAutowireExtension.php b/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/SetUpAutowireExtension.php index 29e0a82d..f71f1c21 100644 --- a/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/SetUpAutowireExtension.php +++ b/packages/tester-bundle/PHPUnit/Extension/SetUpAutowire/SetUpAutowireExtension.php @@ -118,6 +118,13 @@ private function initializeClients(TestCase $testCase): void ); } + // This is to ensure the kernel is not booted before calling createClient + // Can happen if we use the container in a setUpBeforeClass method or a beforeClass hook + ReflectionAccessor::callMethod( + $testCase, + 'ensureKernelShutdown' + ); + foreach ($clientAttributes as [$property, $attribute]) { \assert($property instanceof \ReflectionProperty); \assert($attribute instanceof \ReflectionAttribute); diff --git a/tests/Controller/Security/TwoFactorAuthorizationTest.php b/tests/Controller/Security/TwoFactorAuthorizationTest.php index 0bbf6b79..485f38ff 100644 --- a/tests/Controller/Security/TwoFactorAuthorizationTest.php +++ b/tests/Controller/Security/TwoFactorAuthorizationTest.php @@ -61,11 +61,6 @@ public static function cleanUp(): void ->execute(); } - protected function setUp(): void - { - static::ensureKernelShutdown(); - } - public function testLoginRedirectEnable2fa(): void { static::assertTrue(self::$user->needToEnableTotpAuthenticationEnabled());