Skip to content

Commit d00891a

Browse files
committed
do not require support for releasing savepoints
1 parent a9ff7d7 commit d00891a

File tree

6 files changed

+28
-12
lines changed

6 files changed

+28
-12
lines changed

src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticConnection.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ public function commit(): bool
5454
throw new \BadMethodCallException(sprintf('Bad call to "%s". There is no savepoint for a nested transaction.', __METHOD__));
5555
}
5656

57-
$this->exec($this->platform->releaseSavePoint(self::SAVEPOINT_NAME));
57+
if ($this->platform->supportsReleaseSavepoints()) {
58+
$this->exec($this->platform->releaseSavePoint(self::SAVEPOINT_NAME));
59+
}
5860

5961
$this->nested = false;
6062

src/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function connect(array $params): DriverConnection
5151
? $this->createDatabasePlatformForVersion($params['serverVersion'])
5252
: $this->getDatabasePlatform());
5353

54-
if (!$platform->supportsSavepoints() || !$platform->supportsReleaseSavepoints()) {
54+
if (!$platform->supportsSavepoints()) {
5555
throw new \RuntimeException('This bundle only works for database platforms that support savepoints.');
5656
}
5757

tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/MockDriver.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
use Doctrine\DBAL\Platforms\AbstractPlatform;
99
use Doctrine\DBAL\Platforms\MySQL80Platform;
1010
use Doctrine\DBAL\Schema\AbstractSchemaManager;
11-
use PHPUnit\Framework\MockObject\Generator;
1211

1312
class MockDriver implements Driver
1413
{
1514
private function getMock(string $class)
1615
{
17-
return (new Generator())->getMock(
16+
// TODO: remove this once we drop support for PHPUnit < 10
17+
$generatorClass = class_exists('PHPUnit\Framework\MockObject\Generator')
18+
? 'PHPUnit\Framework\MockObject\Generator'
19+
: 'PHPUnit\Framework\MockObject\Generator\Generator';
20+
21+
/** @phpstan-ignore-next-line */
22+
return (new $generatorClass())->getMock(
1823
$class,
1924
[],
2025
[],

tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriverTest.php

-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ public function testConnectWithPlatform(): void
6969
->method('supportsSavepoints')
7070
->willReturn(true)
7171
;
72-
$platform
73-
->expects(self::exactly(7))
74-
->method('supportsReleaseSavepoints')
75-
->willReturn(true)
76-
;
7772

7873
$params = [
7974
'driver' => 'pdo_mysql',

tests/Functional/PhpunitTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,21 @@ public function testChangeDbStateWithinTransaction(): void
7979
$this->rollbackTransaction();
8080
$this->assertRowCount(0);
8181

82+
$this->beginTransaction();
83+
$this->insertRow();
84+
$this->assertRowCount(1);
85+
$this->rollbackTransaction();
86+
$this->assertRowCount(0);
87+
8288
$this->beginTransaction();
8389
$this->insertRow();
8490
$this->commitTransaction();
8591
$this->assertRowCount(1);
92+
93+
$this->beginTransaction();
94+
$this->insertRow();
95+
$this->commitTransaction();
96+
$this->assertRowCount(2);
8697
}
8798

8899
/**

tests/Functional/app/AppKernel.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace Tests\Functional\app;
44

5+
use DAMA\DoctrineTestBundle\DAMADoctrineTestBundle;
6+
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
57
use Psr\Log\NullLogger;
8+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
69
use Symfony\Component\Config\Loader\LoaderInterface;
710
use Symfony\Component\DependencyInjection\ContainerBuilder;
811
use Symfony\Component\HttpKernel\Kernel;
@@ -12,9 +15,9 @@ class AppKernel extends Kernel
1215
public function registerBundles(): array
1316
{
1417
return [
15-
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
16-
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
17-
new \DAMA\DoctrineTestBundle\DAMADoctrineTestBundle(),
18+
new FrameworkBundle(),
19+
new DoctrineBundle(),
20+
new DAMADoctrineTestBundle(),
1821
];
1922
}
2023

0 commit comments

Comments
 (0)