You are here

public function MolliePaymentOffsiteFormTest::testMolliePaymentStatusExpired in Commerce Mollie 8

Tests MOLLIE payment with EXPIRED status.

/Drupal/commerce_mollie_tests/Services/MollieApiMock returns FAILED when the order amount is exactly "149.95" (5x the test-product with price 29.99).

@todo #2950538 Mock Mollie callback in test-suite

File

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

Class

MolliePaymentOffsiteFormTest
Tests the checkout form that initializes a payment.

Namespace

Drupal\Tests\commerce_mollie\Functional

Code

public function testMolliePaymentStatusExpired() {

  // 5x Add a product to the cart.
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->submitForm([], 'Add to cart');
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->submitForm([], 'Add to cart');
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->submitForm([], 'Add to cart');
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->submitForm([], 'Add to cart');
  $this
    ->drupalGet($this->product
    ->toUrl()
    ->toString());
  $this
    ->submitForm([], 'Add to cart');

  // Goto checkout, proceed payment (go to Mollie).
  $this
    ->helperGotoCheckoutAndProceedPayment();

  // Validations before onNotify() and onReturn().
  $this
    ->helperValidateStatus([
    'commerce_order_status' => 'draft',
    'commerce_order_isPaid' => FALSE,
    'commerce_order_totalPaid' => new Price(0, 'USD'),
    'commerce_payment_status' => 'new',
    'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_EXPIRED,
  ]);

  // First call onNotify().
  $this
    ->helperCallOnNotifyWebhook();

  // Then do onReturn() (go back to website).
  $this
    ->drupalGet('mollie_return/1');
  $this
    ->assertSession()
    ->addressEquals('checkout/1/review');
  $this
    ->assertSession()
    ->pageTextContains('Your payment at Mollie has expired. You may resume the checkout process here when you are ready.');
  $this
    ->assertSession()
    ->pageTextContains('You have canceled checkout at Mollie but may resume the checkout process here when you are ready.');

  // Validations after onNotify() and onReturn().
  $this
    ->helperValidateStatus([
    'commerce_order_status' => 'draft',
    'commerce_order_isPaid' => FALSE,
    'commerce_order_totalPaid' => new Price(0, 'USD'),
    'commerce_payment_status' => 'authorization_expired',
    'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_EXPIRED,
  ]);
}