function DriverSpecificTransactionTestBase::testReleaseIntermediateSavepoint
Same name in other branches
- 10 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificTransactionTestBase::testReleaseIntermediateSavepoint()
Tests releasing a savepoint before last is safe.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ DriverSpecificTransactionTestBase.php, line 673
Class
- DriverSpecificTransactionTestBase
- Tests the transaction abstraction system.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testReleaseIntermediateSavepoint() : void {
$transaction = $this->createRootTransaction();
$savepoint1 = $this->createFirstSavepointTransaction('', FALSE);
// Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_2'
// on the database.
$savepoint2 = $this->connection
->startTransaction();
$this->assertSame(3, $this->connection
->transactionManager()
->stackDepth());
// Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_3'
// on the database.
$savepoint3 = $this->connection
->startTransaction();
$this->assertSame(4, $this->connection
->transactionManager()
->stackDepth());
// Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_4'
// on the database.
$savepoint4 = $this->connection
->startTransaction();
$this->assertSame(5, $this->connection
->transactionManager()
->stackDepth());
$this->insertRow('row');
// Commit a savepoint transaction. Corresponds to 'RELEASE SAVEPOINT
// savepoint_2' on the database.
unset($savepoint2);
// Since we have committed an intermediate savepoint Transaction object,
// the savepoints created later have been dropped by the database already.
$this->assertSame(2, $this->connection
->transactionManager()
->stackDepth());
$this->assertRowPresent('row');
// Commit the remaining Transaction objects. The client transaction is
// eventually committed.
unset($savepoint1);
unset($transaction);
$this->assertFalse($this->connection
->inTransaction());
$this->assertRowPresent('row');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.