Closed mareckigit closed 4 years ago
setUpBeforeClass
methods?I simulate authethication in setUpBeforeClass(). When it's moved to single test, it works.
PDOException {#1263
#message: "There is already an active transaction"
#code: 0
#file: "./vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php"
#line: 126
+errorInfo: null
trace: {
./vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php:126 { …}
./vendor/dama/doctrine-test-bundle/src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php:20 { …}
./bin/.phpunit/phpunit-7.5-0/src/Runner/Hook/TestListenerAdapter.php:40 {
PHPUnit\Runner\TestListenerAdapter->startTest(Test $test): void^
› if ($hook instanceof BeforeTestHook) {
› $hook->executeBeforeTest(TestUtil::describeAsString($test));
› }
}
./bin/.phpunit/phpunit-7.5-0/src/Framework/TestResult.php:406 { …}
./bin/.phpunit/phpunit-7.5-0/src/Framework/TestResult.php:626 { …}
./bin/.phpunit/phpunit-7.5-0/src/Framework/TestCase.php:797 { …}
./bin/.phpunit/phpunit-7.5-0/src/Framework/TestSuite.php:746 { …}
./bin/.phpunit/phpunit-7.5-0/src/Framework/TestSuite.php:746 { …}
./bin/.phpunit/phpunit-7.5-0/src/Framework/TestSuite.php:746 { …}
./bin/.phpunit/phpunit-7.5-0/src/TextUI/TestRunner.php:652 { …}
./bin/.phpunit/phpunit-7.5-0/src/TextUI/Command.php:206 { …}
./bin/.phpunit/phpunit-7.5-0/src/TextUI/Command.php:162 { …}
./bin/.phpunit/phpunit-7.5-0/phpunit:18 { …}
./vendor/symfony/phpunit-bridge/bin/simple-phpunit.php:344 { …}
./bin/phpunit:13 { …}
}
}
Currently there is no way to support that unfortunately :cry:
See https://github.com/dmaicher/doctrine-test-bundle/issues/108
The BeforeTestHook
this bundle uses is executed after the setUpBeforeClass
so all changes done there are not transactional anymore and there is no way to roll them back.
Sorry, I haven't seen this issue. I've added StaticDriver::commit()
to setUpBeforeClass()
and now it works.
It is strange for me that the exception was thrown only when the filter by group was used. Without any filter, when all tests are run, the exception is not thrown. Do you know what's the relationship?
Thanks for help.
Update:
Now, when I'm executing all tests with added StaticDriver::commit()
, exception is thrown from other tests.
Finally I resolved this by https://github.com/dmaicher/doctrine-test-bundle/issues/108#issuecomment-621172305
It is strange for me that the exception was thrown only when the filter by group was used. Without any filter, when all tests are run, the exception is not thrown. Do you know what's the relationship?
probably its because when you run all tests the test does not run as the first test? But when you run only for that group then the test with setUpBeforeClass
runs first? Or the other way around. That would explain it.
When I use:
./bin/phpunit --group mygroup
I get exception: There is already an active transactionWhen I use:
./bin/phpunit
it works.Before installation of doctrine-test-bundle both cases worked correctly.