You are here

public function MolliePaymentOffsiteFormTest::testMolliePaymentStatusOpen in Commerce Mollie 8

Tests MOLLIE payment with OPEN status.

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

@todo #2950538 Mock Mollie callback in test-suite

File

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

Class

MolliePaymentOffsiteFormTest
Tests the checkout form that initializes a payment.

Namespace

Drupal\Tests\commerce_mollie\Functional

Code

public function testMolliePaymentStatusOpen() {

  // 3x 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');

  // 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_OPEN,
  ]);

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

  // Then do onReturn() (go back to website).
  $this
    ->drupalGet('mollie_return/1');
  $this
    ->assertSession()
    ->addressEquals('mollie_return/1');
  $this
    ->assertSession()
    ->pageTextContains('We have not yet received the payment status from Mollie. Please reload this page.');

  // 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',
    'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_OPEN,
  ]);
}