File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545 ->decorate (OrmResetter::class, priority: 10 )
4646 ->args ([
4747 service ('.inner ' ),
48+ param ('kernel.build_dir ' )
4849 ])
4950 ;
5051 }
Original file line number Diff line number Diff line change 1515
1616use DAMA \DoctrineTestBundle \Doctrine \DBAL \StaticDriver ;
1717use Symfony \Component \HttpKernel \KernelInterface ;
18+ use Symfony \Component \HttpKernel \RebootableInterface ;
19+ use Zenstruck \Assert ;
1820use Zenstruck \Foundry \Configuration ;
1921use Zenstruck \Foundry \Persistence \PersistenceManager ;
2022use Zenstruck \Foundry \Persistence \ResetDatabase \ResetDatabaseManager ;
@@ -27,6 +29,7 @@ final class DamaDatabaseResetter implements OrmResetter
2729{
2830 public function __construct (
2931 private OrmResetter $ decorated ,
32+ private string $ kernelBuildDir ,
3033 ) {
3134 }
3235
@@ -50,12 +53,15 @@ public function resetBeforeFirstTest(KernelInterface $kernel): void
5053 Configuration::instance ()->stories ->loadGlobalStories ();
5154 }
5255
53- // shutdown kernel before re-enabling static connections
54- // this would prevent any error if any ResetInterface execute sql queries (example: symfony/doctrine-messenger)
55- $ kernel ->shutdown ();
56-
5756 // re-enable static connections
5857 StaticDriver::setKeepStaticConnections (true );
58+
59+ if (!$ kernel instanceof RebootableInterface) {
60+ throw new \InvalidArgumentException ('Kernel should be rebootable to work with DAMADoctrineTestBundle. ' );
61+ }
62+
63+ // let's reboot the kernel to ensure the static connections will be re-created
64+ $ kernel ->reboot ($ this ->kernelBuildDir );
5965 }
6066
6167 public function resetBeforeEachTest (KernelInterface $ kernel ): void
You can’t perform that action at this time.
0 commit comments