function TransactionTest::createRootTransaction

Create a root Drupal transaction.

22 calls to TransactionTest::createRootTransaction()
TransactionTest::testArbitraryTransactionNames in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests for arbitrary transaction names.
TransactionTest::testCommitAfterDdl in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests commit does not fail when committing after DDL.
TransactionTest::testCommitAfterRollbackSameSavepoint in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests savepoint transaction commit after rollback.
TransactionTest::testCommitWithActiveSavepoint in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests committing a transaction while savepoints are active.
TransactionTest::testQueryFailureInTransaction in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests that transactions can continue to be used if a query fails.

... See full list

File

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

Class

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

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.