You are here

public function BalanceTransactionTest::testBalanceTransactionCreation in Transaction 8

Tests balance transaction creation.

File

tests/src/Kernel/BalanceTransactionTest.php, line 103

Class

BalanceTransactionTest
Tests the balance transactor.

Namespace

Drupal\Tests\transaction\Kernel

Code

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

  // Checks status for new non-executed transaction.
  $this
    ->assertEquals('Unsaved transaction (pending)', $transaction
    ->getDescription());
  $transaction
    ->save();
  $this
    ->assertEquals('Zero amount transaction (pending)', $transaction
    ->getDescription());
  $this
    ->assertEquals([
    $this->logMessage,
  ], $transaction
    ->getDetails());
  $transaction
    ->set('field_amount', -10);
  $this
    ->assertEquals('Debit transaction (pending)', $transaction
    ->getDescription(TRUE));
  $transaction
    ->set('field_amount', 10);
  $this
    ->assertEquals('Credit transaction (pending)', $transaction
    ->getDescription(TRUE));
}