Closed aless673 closed 2 years ago
Would you be able to provide a reproducer? I cannot reproduce this on any of my projects or on the testsuite of the bundle.
Does version 7.1.0 work for you?
Does version 7.1.0 work for you?
same problem with 7.1.0
here the reproducer : https://github.com/aless673/test_rollback_doctrine i did not pushed my docker-compose config
I currently don't have a local postgresql instance available. Quickly tried sqlite and mysql: works fine.
diff --git a/tests/TestitTest.php b/tests/TestitTest.php
index 94d4c26..accff73 100644
--- a/tests/TestitTest.php
+++ b/tests/TestitTest.php
@@ -13,4 +13,13 @@ class TestitTest extends KernelTestCase
'first_name' => 'Alex',
]);
}
+
+ /**
+ * @depends testSomething
+ */
+ public function testSomethingElse(): void
+ {
+ $numberOfUsers = (int) static::getContainer()->get('doctrine.dbal.default_connection')->fetchOne('SELECT COUNT(*) FROM user');
+ self::assertSame(0, $numberOfUsers);
+ }
}
No not sure if this is related to postgresql :thinking: Will try to find some time and setup a local postgresql with docker
@aless673 I just tried it with a docker instance of postgres:latest
and for me this works fine :man_shrugging: on the second test the insert is rolled back.
So for you that second test I added really fails?
@aless673 I just tried it with a docker instance of
postgres:latest
and for me this works fine 🤷♂️ on the second test the insert is rolled back.So for you that second test I added really fails?
public function testSomething(): void
{
static::getContainer()->get('doctrine.dbal.default_connection')->insert('user', [
'last_name' => 'Peter',
'first_name' => 'Alex',
]);
}
public function testSomethingElse(): void
{
$numberOfUsers = (int) static::getContainer()->get('doctrine.dbal.default_connection')->fetchOne('SELECT COUNT(*) FROM user');
self::assertSame(0, $numberOfUsers);
}
Does not work
NB: i am using MySQL
For me this just works with Mysql:
it@32b013e527bd:/var/www/test_rollback_doctrine (main) $ bin/console doctrine:database:drop -f -q
it@32b013e527bd:/var/www/test_rollback_doctrine (main) $ bin/console doctrine:database:create -q
it@32b013e527bd:/var/www/test_rollback_doctrine (main) $ bin/console doctrine:schema:create -q
it@32b013e527bd:/var/www/test_rollback_doctrine (main) $ vendor/bin/phpunit
PHPUnit 9.5.21 #StandWithUkraine
Testing
.. 2 / 2 (100%)
Time: 00:00.094, Memory: 22.00 MB
OK (2 tests, 2 assertions)
Remaining indirect deprecation notices (1)
1x: The "DAMA\DoctrineTestBundle\Doctrine\DBAL\VersionAwarePlatformStaticDriver" class implements "Doctrine\DBAL\VersionAwarePlatformDriver" that is deprecated All drivers will have to be aware of the server version in the next major release.
1x in TestitTest::testSomething from App\Tests
it@32b013e527bd:/var/www/test_rollback_doctrine (main) $ vendor/bin/phpunit
PHPUnit 9.5.21 #StandWithUkraine
Testing
.. 2 / 2 (100%)
Time: 00:00.092, Memory: 22.00 MB
OK (2 tests, 2 assertions)
Remaining indirect deprecation notices (1)
1x: The "DAMA\DoctrineTestBundle\Doctrine\DBAL\VersionAwarePlatformStaticDriver" class implements "Doctrine\DBAL\VersionAwarePlatformDriver" that is deprecated All drivers will have to be aware of the server version in the next major release.
1x in TestitTest::testSomething from App\Tests
i don't have deprecations, probably the bundle is not active. But why..
But tests are running in test
env?
static::bootKernel();
dd(static::$kernel->getEnvironment());
But tests are running in
test
env?static::bootKernel(); dd(static::$kernel->getEnvironment());
yes
PHPUnit 9.5.21 #StandWithUkraine
Testing
"test"
Well then honestly no idea whats happening for you. I cannot reproduce it :cry:
Maybe i am missing something but nothing is rolledback in this simple test
extension is enabled
bundle is enabled
bundle config
Rollback is not working, the data is still changed in DB after test finish :
vendor/bin/phpunit --debug tests/TestitTest.php