doctrine-test-bundle: Bundle seems incompatible with latest releases of doctrine/dbal (2.9.3 and 2.10.0)
Problem arises with upgrading to doctrine/dbal:2.9.3 and doctrine/dbal:2.10.0.
PHP Fatal error: Uncaught PDOException: There is no active transaction in /projects/xxx/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php:140
Stack trace:
#0 /projects/xxx/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php(140): PDO->rollBack()
#1 /projects/xxx/vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php(25): DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver::rollBack()
#2 /projects/xxx/vendor/phpunit/phpunit/src/Runner/Hook/TestListenerAdapter.php(128): DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension->executeAfterTest('Tests\\XXX\\Appli...', 0.28703999519348)
#3 /projects/xxx/vendor/phpunit/phpunit/src/Framework/TestResult.php(423): PHPUnit\Runner\TestListenerAdapter->endTest(Object(Tests\XXX\Application\Website\Controller\Article\DetailControllerTest), 0.28703999519348)
#4 /projects/xxx/vendor/phpunit/phpunit/src/Framework/TestResult.php(933) in /projects/xxx/templates/website/base.html.twig on line 143
Reverting back to doctrine/dbal:2.9.2 makes my testsuite run again.
Probably the few(er) changes in https://github.com/doctrine/dbal/releases/tag/v2.9.3 (in stead of v2.10.0) narrows the problem down, as both new releases throw the same exception.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 31 (11 by maintainers)
Perfect 😊 Thanks for the fast feedback.
I will release this tomorrow as patch releases 5.0.4 (just revived 5.x https://github.com/dmaicher/doctrine-test-bundle/pull/96) and 6.2.1.
@evertharmeling @binarious @jaikdean can you test this fix?
https://github.com/dmaicher/doctrine-test-bundle/compare/issue-94?expand=1
I might have found a solution for the problem
You’re not the only one. I was hit by this today, too. Every functional test that calls
flush()of the EntityManager raises this error for me. I’m currently trying to extract a simple test case.Confirmed working. Thanks for the super quick fix, @dmaicher!
I can reproduce it now 👍 investigating what is going on
Got one. This one does it for me: https://gist.github.com/binarious/51044562e232fce0a91940188287a6e8
The combination of
static::createClient()and$this->em->flush()seems to be problematic. If one of these lines is removed, the error goes away.doctrine/dbal2.9.2 works. 2.9.3+ not.Output:
The issue on
bolt/corewas related to running DDL statements during tests and implicitly committing the open transaction on the connection.See https://github.com/bolt/core/pull/715
Hi all,
Just chiming in, we’ve bumped into the same issue. Details here: https://github.com/bolt/core/issues/702
I can confirm commenting the line
$this->transactionNestingLevel = 0;“fixes” it.Modifying
beginTransactioninStaticDriverto this:Still gives the error.
Additional notes: first broke on Doctrine/dbal 2.9.3, also tried 2.10.0… Initially had it locked on
dama/doctrine-test-bundle5.x (to keep parity with SF 4), tried updating it to 6.2, but the results are unchanged.Removing this line https://github.com/doctrine/dbal/commit/a9b7bf855c6f391f96773f844d7158500394bcef#diff-7b1e94fb7dd408985f7b7973330dc2edR359 fixes the issue. dama/doctrine-test-bundle v5.0.2 and v6.2.0 doctrine/dbal v2.10.0
Sterling work, that’s fixed the issue for us too, @dmaicher
Confirmed working too! Nice job @dmaicher!
Ah this is probably my problem too, I will check it out tomorrow!
Using
enable_static_connection: falseessentially disables the main purpose of the bundle and disables transaction roll-back on tests. So we should find a proper fix 😄@evertharmeling can you try this change and see if there was an exception thrown in your case that was silenced?
https://github.com/dmaicher/doctrine-test-bundle/compare/small_cleanup?expand=1#diff-e67e9cb1cc462500be1b82d2d5f56fe0L129
I tried one more private project and also
symfony/demoand I cannot reproduce any errors unfortunately 😕Using the latest,
dama/doctrine-test-bundle:6.2.0@dmaicher Our particular issue isn’t there with
doctrine/dbal:2.9.3. We’re usingdama/doctrine-test-bundle:6.2.0.I’ll try to come up with a test case and will update with anything I can figure out, we just have a lot of moving parts to look at on this project.