-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDOException: There is no active transaction #197
Comments
Thanks for the report. Does it work if you call the container in another way? Like this:
|
Hey, sorry for the long wait. I tried that too, the Error Message stays the same. |
I can't reproduce this issue in a Symfony 5.4 project that run tests with PHPUnit 9.5 on PHP 7.4, 8.0 and 8.1, on a MySQL database. Could you please share a reproducer? The Symfony doc explains how to do it. Please commit the minimal code to reproduce the issue, without forgetting the Here is my test class: full codeclass ControllerTest extends WebTestCase
{
protected KernelBrowser $testClient;
protected AbstractDatabaseTool $databaseTool;
protected function setUp(): void
{
parent::setUp();
$this->testClient = static::createClient();
self::bootKernel();
$container = self::$kernel->getContainer();
/** @var DatabaseToolCollection $dbToolCollection */
$dbToolCollection = $container->get(DatabaseToolCollection::class);
$this->databaseTool = $dbToolCollection->get();
}
public function testLeaderboardsNumberOfBadgesNoUser(): void
{
$this->databaseTool->loadFixtures([]);
$path = '/users/leaderboards/badges/';
$crawler = $this->testClient->request('GET', $path);
$this->assertSame(404, $this->testClient->getResponse()->getStatusCode());
}
protected function tearDown(): void
{
parent::tearDown();
unset($this->databaseTool);
}
} |
I was able to reproduce this issue on a different and unrelated PR (#109):
full log (they may be deleted in the future) The error only appear with PHP 8.0 and 8.1, so it may be due to different versions of dependencies. But the tests are randomized so we can't be sure. It may be related to doctrine/DoctrineFixturesBundle#348 and/or doctrine/DoctrineFixturesBundle#363 |
Sorry i wasn't able to build a reproducer till this day, i'm trying to work on this now. |
So it looks like the creation and deletion of the dabase causes this error, I didn't found a solution yet. Please try this workaround: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/caveats.md#damadoctrinetestbundle liip_test_fixtures:
keep_database_and_schema: true |
Have you found the solution? I'm facing the same issue. |
Same here. Using: public function setUp(): void
{
parent::setUp();
$this->client = static::createClient();
$this->databaseTool = static::getContainer()->get(DatabaseToolCollection::class)->get();
}
public function testIndexAction(): void
{
$this->databaseTool->loadFixtures([Fixtures::class]);
// ... |
Issue still persist in 2024 PHP 8.3 |
I can't reproduce this error with dependencies like this: {
"[…]": "[…]",
"require": {
"php": ">=8.3",
"[…]": "[…]",
"doctrine/doctrine-bundle": "^2.13.0",
"doctrine/doctrine-migrations-bundle": "^3.3.1",
"doctrine/orm": "^3.2.2",
"[…]": "[…]",
"symfony/framework-bundle": "^6.4.12",
"[…]": "[…]"
},
"require-dev": {
"[…]": "[…]",
"doctrine/doctrine-fixtures-bundle": "^3.6.1",
"liip/test-fixtures-bundle": "^3.1.0",
"phpunit/phpunit": "^11.3.6",
"[…]": "[…]",
"symfony/phpunit-bridge": "^6.4.11",
"[…]": "[…]"
},
"[…]": "[…]",
} With and without the workaround from #197 (comment) If you can create a project to reproduce this issue, please check this: #197 (comment) |
Same issue here. However changing value of the |
Hey,
When i try to load Fixtures, pdo throws the exception from above. I found a workaround using TransactionHelper from Doctrine, but therefore i have to edit the Doctrine EntityManager, and i don't think that this should be the way to go.
using this code, i get the following stacktrace:
I'm using PHP 8.1.7, PHPUnit 8.5.27,
liip/test-fixtures-bundle 2.4.0
Maybe you got a solution, on how to fix this Problem.
Ps. It's my first time, writing an Issue, so if sth. is missing, please tell me.
The text was updated successfully, but these errors were encountered: