Skip to content

Commit

Permalink
Rollback all nested transactions created within test (#5107) (#5243)
Browse files Browse the repository at this point in the history
This fixes tests in which other transactions are created but not closed for various reasons.
  • Loading branch information
Dukecz authored and DavertMik committed Oct 26, 2018
1 parent b7d53c8 commit 71c4c0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Codeception/Module/Doctrine2.php
Expand Up @@ -163,7 +163,9 @@ public function _after(TestInterface $test)
}
if ($this->config['cleanup'] && $this->em->getConnection()->isTransactionActive()) {
try {
$this->em->getConnection()->rollback();
while ($this->em->getConnection()->getTransactionNestingLevel() > 0) {
$this->em->getConnection()->rollback();
}
$this->debugSection('Database', 'Transaction cancelled; all changes reverted.');
} catch (\PDOException $e) {
}
Expand Down

0 comments on commit 71c4c0c

Please sign in to comment.