From db467f090c840671ad09eb4cec93ebd6a3836084 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Sat, 19 Oct 2024 12:12:38 +0200 Subject: [PATCH 1/2] Cover scenario `BEGIN TRANSACTION; COMMIT; BEGIN TRANSACTION; --failure` https://github.com/doctrine/dbal/pull/6545#issuecomment-2412377607 --- tests/ConnectionTest.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 10e1ea4d77..1b098d8eee 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -32,6 +32,7 @@ use PHPUnit\Framework\TestCase; use Psr\Cache\CacheItemInterface; use Psr\Cache\CacheItemPoolInterface; +use RuntimeException; use stdClass; /** @requires extension pdo_mysql */ @@ -413,6 +414,35 @@ public function testCommitStartsTransactionInNoAutoCommitMode(): void self::assertTrue($conn->isTransactionActive()); } + public function testBeginTransactionFailureAfterCommitInNoAutoCommitMode(): void + { + $driverConnectionMock = $this->createMock(DriverConnection::class); + $driverConnectionMock->expects(self::exactly(2)) + ->method('beginTransaction') + ->willReturnOnConsecutiveCalls( + true, + self::throwException(new RuntimeException()), + ); + + $driver = $this->createStub(Driver::class); + $driver + ->method('connect') + ->willReturn( + $driverConnectionMock, + ); + $conn = new Connection([], $driver); + + $conn->setAutoCommit(false); + + $conn->connect(); + try { + $conn->commit(); + } catch (RuntimeException $e) { + } + + self::assertTrue($conn->isTransactionActive()); + } + /** @dataProvider resultProvider */ public function testCommitReturn(bool $expectedResult): void { From 53bde79a7486563163efabbbcc675845f495bfb7 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 22 Oct 2024 03:35:44 +0200 Subject: [PATCH 2/2] Run tests with MySQL 9.1 (#6568) --- .github/workflows/continuous-integration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 56558bc7f0..4be5b0ecc6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -399,7 +399,7 @@ jobs: mysql-version: - "5.7" - "8.0" - - "9.0" + - "9.1" extension: - "mysqli" - "pdo_mysql" @@ -428,10 +428,10 @@ jobs: custom-entrypoint: >- --entrypoint sh mysql:8.4 -c "exec docker-entrypoint.sh mysqld --mysql-native-password=ON" - php-version: "8.4" - mysql-version: "9.0" + mysql-version: "9.1" extension: "mysqli" - php-version: "8.4" - mysql-version: "9.0" + mysql-version: "9.1" extension: "pdo_mysql" services: