public function MolliePaymentOffsiteFormTest::testMolliePaymentStatusFailed in Commerce Mollie 8
Tests MOLLIE payment with FAILED status.
/Drupal/commerce_mollie_tests/Services/MollieApiMock returns FAILED when the order amount is exactly "119.96" (4x the test-product with price 29.99).
@todo #2950538 Mock Mollie callback in test-suite
File
- tests/
src/ Functional/ MolliePaymentOffsiteFormTest.php, line 256
Class
- MolliePaymentOffsiteFormTest
- Tests the checkout form that initializes a payment.
Namespace
Drupal\Tests\commerce_mollie\FunctionalCode
public function testMolliePaymentStatusFailed() {
// 4x 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');
// 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_FAILED,
]);
// 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 failed. 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_voided',
'commerce_payment_remoteStatus' => MolliePaymentStatus::STATUS_FAILED,
]);
}