function TransactionManagerTest::testTransactionRollbackToSavepoint
Tests rolling back a transaction to a savepoint.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ TransactionManagerTest.php, line 255
Class
- TransactionManagerTest
- Tests transactions.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testTransactionRollbackToSavepoint() : void {
$tx = $this->connection
->startTransaction();
$savepoint = $this->connection
->startTransaction('foo');
$savepoint->rollback();
$this->assertSame(1, $this->connection
->transactionManager()
->stackDepth());
$this->assertFalse($this->connection
->transactionManager()
->has('foo'));
$this->assertTrue($this->connection
->transactionManager()
->has('drupal_transaction'));
$this->assertTrue($this->connection
->inTransaction());
$tx->commitOrRelease();
$this->assertSame(0, $this->connection
->transactionManager()
->stackDepth());
$this->assertFalse($this->connection
->transactionManager()
->has('foo'));
$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.