function TransactionManagerTest::testStateAfterStartSavepointFailure
Checks TransactionManager after failing to start a savepoint.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ TransactionManagerTest.php, line 110
Class
- TransactionManagerTest
- Tests transactions.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testStateAfterStartSavepointFailure() : void {
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$tx = $this->connection
->startTransaction();
try {
$this->connection
->transactionManager()->success = FALSE;
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
$savepoint = $this->connection
->startTransaction('foo');
} catch (TransactionException) {
// Continue.
}
$this->assertSame(0, $this->connection
->transactionManager()
->stackDepth());
$this->assertFalse($this->connection
->transactionManager()
->has('drupal_transaction'));
$this->assertFalse($this->connection
->inTransaction());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.