function TransactionTest::createFirstSavepointTransaction

Create a Drupal savepoint transaction after root.

14 calls to TransactionTest::createFirstSavepointTransaction()
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::testReleaseIntermediateSavepoint in core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Tests releasing a savepoint before last is safe.

... See full list

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Database

Code

protected function createFirstSavepointTransaction(string $name = '', bool $insertRow = TRUE) : Transaction {
    $this->assertTrue($this->connection
        ->inTransaction());
    $this->assertSame(1, $this->connection
        ->transactionManager()
        ->stackDepth());
    // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_1'
    // on the database. The name can be changed by the $name argument.
    $savepoint = $this->connection
        ->startTransaction($name);
    $this->assertTrue($this->connection
        ->inTransaction());
    $this->assertSame(2, $this->connection
        ->transactionManager()
        ->stackDepth());
    // Insert a single row into the testing table.
    if ($insertRow) {
        $this->insertRow('Roger');
        $this->assertRowPresent('Roger');
    }
    return $savepoint;
}

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