You are here

public function UserPointsTransactionTest::testUserPointsTransactionCreation in User Points 8

Tests user points transaction creation.

@covers \Drupal\userpoints\Plugin\Transaction\UserPointsTransactor

File

tests/src/Kernel/UserPointsTransactionTest.php, line 147

Class

UserPointsTransactionTest
Tests the user points transactor.

Namespace

Drupal\Tests\userpoints\Kernel

Code

public function testUserPointsTransactionCreation() {
  $transaction = $this->transaction;
  $transactor = $transaction
    ->getType()
    ->getPlugin();

  // Checks status for new non-executed transaction.
  $this
    ->assertEquals('Zero points transaction (pending)', $transaction
    ->getDescription());
  $this
    ->assertEquals('The current user points balance will not be altered.', $transactor
    ->getExecutionIndications($transaction));
  $this
    ->assertEquals([
    $this->logMessage,
  ], $transaction
    ->getDetails());
  $transaction
    ->set('field_amount', -10);
  $this
    ->assertEquals('Points debit (pending)', $transaction
    ->getDescription(TRUE));
  $this
    ->assertEquals('The user will loss 10 points.', $transactor
    ->getExecutionIndications($transaction));
  $transaction
    ->set('field_amount', 10);
  $this
    ->assertEquals('Points credit (pending)', $transaction
    ->getDescription(TRUE));
  $this
    ->assertEquals('The user will gain 10 points.', $transactor
    ->getExecutionIndications($transaction));
}