function TransactionManagerTest::testTransactionCommitFailure

Tests a transaction commit failure.

File

core/tests/Drupal/Tests/Core/Database/TransactionManagerTest.php, line 140

Class

TransactionManagerTest
Tests transactions.

Namespace

Drupal\Tests\Core\Database

Code

public function testTransactionCommitFailure() : void {
  $tx = $this->connection
    ->startTransaction();
  $this->connection
    ->transactionManager()->success = FALSE;
  $this->expectException(TransactionCommitFailedException::class);
  $this->expectExceptionMessage('Failed commit of transaction');
  $tx->commitOrRelease();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.