Skip to content

Commit

Permalink
Ensure that Doctrine's UnitOfWork contents are cleaned up after popul…
Browse files Browse the repository at this point in the history
…ating database. Fixes theofidry#26
  • Loading branch information
FlyingDR committed Sep 19, 2022
1 parent 0dd4e9e commit 0ec404d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/PhpUnit/BaseDatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
5 changes: 5 additions & 0 deletions tests/PhpUnit/RefreshTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
*/
trait RefreshTestTrait
{
public function testUnitOfWorkIsEmptyAtTheStartOfTheTest(): void
{
self::assertEquals(0, $this->getManager()->getUnitOfWork()->size());
}

public function testRefresh(): void
{
$manager = $this->getManager();
Expand Down

0 comments on commit 0ec404d

Please sign in to comment.