Skip to content

Commit

Permalink
Merge pull request #6585 from greg0ire/4.2.x
Browse files Browse the repository at this point in the history
Merge 2161a70 up into 4.2.x
  • Loading branch information
greg0ire authored Nov 5, 2024
2 parents 5ddafce + 9326373 commit dae8c84
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,5 @@ test_script:
after_test:
- appveyor DownloadFile https://codecov.io/bash -FileName codecov.sh
- bash codecov.sh -f clover.xml
- SET upload_name=appveyor-%db%-%db_version%-%driver%-php-%php%
- bash codecov.sh -f clover.xml -n %upload_name%
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -654,5 +654,6 @@ jobs:
with:
directory: reports
fail_ci_if_error: true
name: github-action
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
51 changes: 51 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,57 @@ public function testConnectStartsTransactionInNoAutoCommitMode(): void
self::assertTrue($conn->isTransactionActive());
}

public function testTransactionIsNotActiveAfterTransactionalInAutoCommitMode(): void
{
$driverMock = self::createStub(Driver::class);
$driverMock
->method('connect')
->willReturn(
self::createStub(DriverConnection::class),
);

$conn = new Connection([], $driverMock);

$conn->setAutoCommit(true);

self::assertFalse($conn->isTransactionActive());

$conn->transactional(static function (Connection $connection): void {
});

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

public function testTransactionIsActiveAfterTransactionalInNoAutoCommitMode(): void
{
$platformMock = $this->createMock(AbstractPlatform::class);
$platformMock
->method('supportsSavepoints')
->willReturn(true);

$driverMock = $this->createMock(Driver::class);
$driverMock
->method('connect')
->willReturn(
self::createStub(DriverConnection::class),
);

$driverMock
->method('getDatabasePlatform')
->willReturn(
$platformMock,
);

$conn = new Connection([], $driverMock);

$conn->setAutoCommit(false);

$conn->transactional(static function (Connection $connection): void {
});

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

public function testCommitStartsTransactionInNoAutoCommitMode(): void
{
$driver = self::createStub(Driver::class);
Expand Down

0 comments on commit dae8c84

Please sign in to comment.