function DriverSpecificTransactionTestBase::createRootTransaction

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php \Drupal\KernelTests\Core\Database\DriverSpecificTransactionTestBase::createRootTransaction()

Create a root Drupal transaction.

15 calls to DriverSpecificTransactionTestBase::createRootTransaction()
DriverSpecificTransactionTestBase::testCommitWithActiveSavepoint in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
Tests committing a transaction while savepoints are active.
DriverSpecificTransactionTestBase::testQueryFailureInTransaction in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
Tests that transactions can continue to be used if a query fails.
DriverSpecificTransactionTestBase::testReleaseIntermediateSavepoint in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
Tests releasing a savepoint before last is safe.
DriverSpecificTransactionTestBase::testRollbackRoot in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
Tests root transaction rollback.
DriverSpecificTransactionTestBase::testRollbackRootAfterSavepointRollback in core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
Tests root transaction rollback after savepoint rollback.

... See full list

File

core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php, line 51

Class

DriverSpecificTransactionTestBase
Tests the transaction abstraction system.

Namespace

Drupal\KernelTests\Core\Database

Code

protected function createRootTransaction(string $name = '', bool $insertRow = TRUE) : Transaction {
    $this->assertFalse($this->connection
        ->inTransaction());
    $this->assertSame(0, $this->connection
        ->transactionManager()
        ->stackDepth());
    // Start root transaction. Corresponds to 'BEGIN TRANSACTION' on the
    // database.
    $transaction = $this->connection
        ->startTransaction($name);
    $this->assertTrue($this->connection
        ->inTransaction());
    $this->assertSame(1, $this->connection
        ->transactionManager()
        ->stackDepth());
    // Insert a single row into the testing table.
    if ($insertRow) {
        $this->insertRow('David');
        $this->assertRowPresent('David');
    }
    return $transaction;
}

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