Skip to content
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

Merge 3.9.x up into 4.2.x #6570

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 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,36 @@ 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);

/** Invoke protected {@see Connection::connect()} */
$conn->getServerVersion();
try {
$conn->commit();
} catch (RuntimeException) {
}

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

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