diff --git a/src/PhpUnit/BaseDatabaseTrait.php b/src/PhpUnit/BaseDatabaseTrait.php index f1849b9..cdccb97 100644 --- a/src/PhpUnit/BaseDatabaseTrait.php +++ b/src/PhpUnit/BaseDatabaseTrait.php @@ -66,14 +66,16 @@ protected static function ensureKernelTestCase(): void protected static function populateDatabase(): void { $container = static::$kernel->getContainer(); + $manager = $container->get('doctrine')->getManager(static::$manager); static::$fixtures = $container->get('hautelook_alice.loader')->load( new Application(static::$kernel), // OK this is ugly... But there is no other way without redesigning LoaderInterface from the ground. - $container->get('doctrine')->getManager(static::$manager), + $manager, static::$bundles, static::$kernel->getEnvironment(), static::$append, static::$purgeWithTruncate, static::$shard ); + $manager->clear(); } } diff --git a/tests/PhpUnit/RefreshTestTrait.php b/tests/PhpUnit/RefreshTestTrait.php index d1f83c3..96c7067 100644 --- a/tests/PhpUnit/RefreshTestTrait.php +++ b/tests/PhpUnit/RefreshTestTrait.php @@ -22,6 +22,11 @@ */ trait RefreshTestTrait { + public function testUnitOfWorkIsEmptyAtTheStartOfTheTest(): void + { + self::assertEquals(0, $this->getManager()->getUnitOfWork()->size()); + } + public function testRefresh(): void { $manager = $this->getManager();