You are here

public function GenericTransactionTest::testGenericTransactionOperation in Transaction 8

Tests generic transaction execution with operation.

File

tests/src/Kernel/GenericTransactionTest.php, line 75

Class

GenericTransactionTest
Tests the generic transactor.

Namespace

Drupal\Tests\transaction\Kernel

Code

public function testGenericTransactionOperation() {
  $transaction = $this->transaction;

  // Sets an operation to the transaction and executes it.
  $transaction
    ->setOperation($this->transactionOperation)
    ->execute();

  // Checks if the transaction description and details are composed from their
  // templates in the operation.
  $this
    ->assertEquals('Test generic #1', $transaction
    ->getDescription());
  $expected_details = [
    $this->logMessage,
    'Executed by UID: ' . $transaction
      ->getExecutorId(),
    'Transaction UUID: ' . $transaction
      ->uuid(),
  ];
  $this
    ->assertEquals($expected_details, $transaction
    ->getDetails());
}