You are here

protected function MolliePaymentOffsiteFormTest::helperValidateStatus in Commerce Mollie 8

Validates Order and Payments statuses.

5 calls to MolliePaymentOffsiteFormTest::helperValidateStatus()
MolliePaymentOffsiteFormTest::testMolliePaymentStatusCanceled in tests/src/Functional/MolliePaymentOffsiteFormTest.php
Tests MOLLIE payment with CANCELED status.
MolliePaymentOffsiteFormTest::testMolliePaymentStatusExpired in tests/src/Functional/MolliePaymentOffsiteFormTest.php
Tests MOLLIE payment with EXPIRED status.
MolliePaymentOffsiteFormTest::testMolliePaymentStatusFailed in tests/src/Functional/MolliePaymentOffsiteFormTest.php
Tests MOLLIE payment with FAILED status.
MolliePaymentOffsiteFormTest::testMolliePaymentStatusOpen in tests/src/Functional/MolliePaymentOffsiteFormTest.php
Tests MOLLIE payment with OPEN status.
MolliePaymentOffsiteFormTest::testMolliePaymentStatusPaid in tests/src/Functional/MolliePaymentOffsiteFormTest.php
Tests MOLLIE payment with PAID status.

File

tests/src/Functional/MolliePaymentOffsiteFormTest.php, line 389

Class

MolliePaymentOffsiteFormTest
Tests the checkout form that initializes a payment.

Namespace

Drupal\Tests\commerce_mollie\Functional

Code

protected function helperValidateStatus($validations = []) {

  /** @var \Drupal\commerce_order\Entity\Order $order */
  $this->orderStorage
    ->resetCache([
    1,
  ]);
  $order = $this->orderStorage
    ->load(1);

  /** @var \Drupal\commerce_payment\Entity\Payment $payment */
  $this->paymentStorage
    ->resetCache([
    1,
  ]);
  $payment = $this->paymentStorage
    ->load(1);

  // Order validations.
  if (array_key_exists('commerce_order_status', $validations)) {
    $this
      ->assertEquals($validations['commerce_order_status'], $order
      ->getState()->value);
  }
  if (array_key_exists('commerce_order_isPaid', $validations)) {
    $this
      ->assertEquals($validations['commerce_order_isPaid'], $order
      ->isPaid());
  }
  if (array_key_exists('commerce_order_totalPaid', $validations)) {
    $this
      ->assertEquals($validations['commerce_order_totalPaid'], $order
      ->getTotalPaid());
  }

  // Payment validations.
  if (array_key_exists('commerce_payment_status', $validations)) {
    $this
      ->assertEquals($validations['commerce_payment_status'], $payment
      ->getState()->value);
  }
  if (array_key_exists('commerce_payment_remoteStatus', $validations)) {
    $this
      ->assertEquals($validations['commerce_payment_remoteStatus'], $payment
      ->getRemoteState());
  }
}