function TransactionTest::testRollbackRootAfterSavepointRollback

Tests root transaction rollback after savepoint rollback.

File

core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php, line 196

Class

TransactionTest
Tests the transactions, using the explicit ::commitOrRelease method.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testRollbackRootAfterSavepointRollback() : void {
  $transaction = $this->createRootTransaction();
  $savepoint = $this->createFirstSavepointTransaction();
  // Rollback savepoint. It should get released too. Corresponds to 'ROLLBACK
  // TO savepoint_1' plus 'RELEASE savepoint_1' on the database.
  $savepoint->rollBack();
  $this->assertRowPresent('David');
  $this->assertRowAbsent('Roger');
  $this->assertTrue($this->connection
    ->inTransaction());
  $this->assertSame(1, $this->connection
    ->transactionManager()
    ->stackDepth());
  // Try to rollback root. No savepoint is active, this should succeed.
  $transaction->rollBack();
  $this->assertRowAbsent('David');
  $this->assertRowAbsent('Roger');
  $this->assertFalse($this->connection
    ->inTransaction());
  $this->assertSame(0, $this->connection
    ->transactionManager()
    ->stackDepth());
}

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