You are here

public function MolliePaymentOffsiteFormTest::testMolliePaymentStatusCanceled in Commerce Mollie 8

Tests MOLLIE payment with CANCELED status.

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

@todo #2950538 Mock Mollie callback in test-suite

File

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

Class

MolliePaymentOffsiteFormTest
Tests the checkout form that initializes a payment.

Namespace

Drupal\Tests\commerce_mollie\Functional

Code

public function testMolliePaymentStatusCanceled() {

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

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

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