Skip to content

Commit

Permalink
Add a fix for transactional database test
Browse files Browse the repository at this point in the history
  • Loading branch information
vokomarov committed Apr 19, 2023
1 parent 275f295 commit c4a80ab
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ protected function scopedDatabase(): void
$db = $this->getContainer()->get(DatabaseInterface::class);
$db->begin();

// $this->getContainer()->get(FinalizerInterface::class)->addFinalizer(static function () use ($db) {
// $db->rollback();
// });
$this->getContainer()->get(FinalizerInterface::class)->addFinalizer(static function () use ($db) {
/** @var \Cycle\Database\DatabaseInterface $db */
$db = $this->getContainer()->get(DatabaseInterface::class);

while ($db->getDriver()->getTransactionLevel() !== 0) {
if (! $db->rollback()) {
return;
}
}
});
}

protected function scopedDatabaseFinalise(): void
Expand All @@ -82,7 +89,7 @@ protected function scopedDatabaseFinalise(): void

protected function tearDown(): void
{
$this->scopedDatabaseFinalise();
// $this->scopedDatabaseFinalise();

parent::tearDown();

Expand Down

0 comments on commit c4a80ab

Please sign in to comment.