function TransactionTest::testArbitraryTransactionNames

Tests for arbitrary transaction names.

File

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

Class

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

Namespace

Drupal\KernelTests\Core\Database

Code

public function testArbitraryTransactionNames() : void {
    $transaction = $this->createRootTransaction('TinkyWinky', FALSE);
    // Despite setting a name, the root transaction is always named
    // 'drupal_transaction'.
    $this->assertSame('drupal_transaction', $transaction->name());
    $savepoint1 = $this->createFirstSavepointTransaction('Dipsy', FALSE);
    $this->assertSame('Dipsy', $savepoint1->name());
    $this->expectException(TransactionNameNonUniqueException::class);
    $this->expectExceptionMessage("Dipsy is already in use.");
    $this->connection
        ->startTransaction('Dipsy');
}

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