You are here

public function GenericTransactionTest::testGenericTransactionExecution in Transaction 8

Tests generic transaction execution.

File

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

Class

GenericTransactionTest
Tests the generic transactor.

Namespace

Drupal\Tests\transaction\Kernel

Code

public function testGenericTransactionExecution() {
  $transaction = $this->transaction;
  $this
    ->assertTrue($transaction
    ->execute());

  // Checks the transaction status after its execution.
  $this
    ->assertEquals('Transaction 1', $transaction
    ->getDescription());
  $this
    ->assertNotNull($transaction
    ->getExecutionTime());
  $this
    ->assertEquals(User::getAnonymousUser()
    ->id(), $transaction
    ->getExecutorId());
  $this
    ->assertGreaterThan(0, $transaction
    ->getResultCode());
  $this
    ->assertEquals('Transaction executed successfully.', $transaction
    ->getResultMessage());
  $this
    ->assertEquals($transaction
    ->id(), $this->targetEntity
    ->get('field_last_transaction')->target_id);
}