function DriverSpecificTransactionTestBase::testRootTransactionEndCallbackCalledOnRollback

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

Tests post-transaction callback executes after transaction rollback.

File

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

Class

DriverSpecificTransactionTestBase
Tests the transaction abstraction system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testRootTransactionEndCallbackCalledOnRollback() : void {
    $transaction = $this->createRootTransaction('', FALSE);
    $this->connection
        ->transactionManager()
        ->addPostTransactionCallback([
        $this,
        'rootTransactionCallback',
    ]);
    $this->insertRow('row');
    $this->assertNull($this->postTransactionCallbackAction);
    $transaction->rollBack();
    $this->assertSame('rtcRollback', $this->postTransactionCallbackAction);
    unset($transaction);
    $this->assertRowAbsent('row');
    // The row insert should be missing since the client rollback occurs after
    // the processing of the callbacks.
    $this->assertRowAbsent('rtcRollback');
}

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