You are here

public function MolliePaymentOffsiteFormTest::testMolliePaymentStatusPaid in Commerce Mollie 8

Tests MOLLIE payment with PAID status.

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

@todo #2950538 Mock Mollie callback in test-suite

File

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

Class

MolliePaymentOffsiteFormTest
Tests the checkout form that initializes a payment.

Namespace

Drupal\Tests\commerce_mollie\Functional

Code

public function testMolliePaymentStatusPaid() {

  // 1x Add a product to the 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_PAID,
  ]);

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

  // Then do onReturn() (go back to website).
  $this
    ->drupalGet('mollie_return/1');
  $this
    ->assertSession()
    ->addressEquals('checkout/1/complete');
  $this
    ->assertSession()
    ->pageTextContains('Your order number is 1. You can view your order on your account page when logged in.');
  $this
    ->assertSession()
    ->pageTextContains('Thank you for your payment with Mollie. We will inform you when your payment is processed. This is usually done within 24 hours.');

  // Validations after onNotify() and onReturn().
  $this
    ->helperValidateStatus([
    'commerce_order_status' => 'validation',
    'commerce_order_isPaid' => TRUE,
    'commerce_order_totalPaid' => new Price(29.99, 'USD'),
    'commerce_payment_status' => 'completed',
    'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_PAID,
  ]);
}