Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.9.x' into 4.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Oct 22, 2024
2 parents e729f88 + 53bde79 commit 599460b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ jobs:
mysql-version:
- "5.7"
- "8.0"
- "9.0"
- "9.1"
extension:
- "mysqli"
- "pdo_mysql"
Expand Down Expand Up @@ -401,10 +401,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:
Expand Down
30 changes: 30 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use PHPUnit\Framework\TestCase;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use RuntimeException;

/** @psalm-import-type Params from DriverManager */
#[RequiresPhpExtension('pdo_mysql')]
Expand Down Expand Up @@ -172,6 +173,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 = self::createStub(Driver::class);
$driver
->method('connect')
->willReturn(
$driverConnectionMock,
);
$conn = new Connection([], $driver);

$conn->setAutoCommit(false);

$conn->getServerVersion(); // causes a call to connect(), which is protected
try {
$conn->commit();
} catch (RuntimeException) {
}

self::assertTrue($conn->isTransactionActive());
}

/** @return bool[][] */
public static function resultProvider(): array
{
Expand Down

0 comments on commit 599460b

Please sign in to comment.