Skip to content

Commit 6052e81

Browse files
authored
[minor] Revert "[bug] fix global state with symfony/framework-bundle >= 5.4.6/6.0.6" (#260)
This reverts commit c131715.
1 parent 71f08af commit 6052e81

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Test/DatabaseResetter.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver;
66
use Symfony\Bundle\FrameworkBundle\Console\Application;
77
use Symfony\Component\HttpKernel\KernelInterface;
8+
use Zenstruck\Foundry\Factory;
89

910
/**
1011
* @internal
@@ -41,7 +42,7 @@ public static function resetDatabase(KernelInterface $kernel): void
4142

4243
$databaseResetter->resetDatabase();
4344

44-
self::flushGlobalState($kernel);
45+
self::bootFoundry($kernel);
4546

4647
self::$hasBeenReset = true;
4748
}
@@ -56,7 +57,7 @@ public static function resetSchema(KernelInterface $kernel): void
5657
return;
5758
}
5859

59-
self::flushGlobalState($kernel);
60+
self::bootFoundry($kernel);
6061
}
6162

6263
/** @retrun array<SchemaResetterInterface> */
@@ -76,9 +77,11 @@ private static function schemaResetters(KernelInterface $kernel): array
7677
return $databaseResetters;
7778
}
7879

79-
private static function flushGlobalState(KernelInterface $kernel): void
80+
private static function bootFoundry(KernelInterface $kernel): void
8081
{
81-
TestState::bootFromContainer($kernel->getContainer());
82+
if (!Factory::isBooted()) {
83+
TestState::bootFromContainer($kernel->getContainer());
84+
}
8285

8386
TestState::flushGlobalState();
8487
}

0 commit comments

Comments
 (0)