public function CouponRedemptionPaneTest::testCheckoutWithMainSubmit in Commerce Core 8.2
Tests checkout using the main submit button instead of 'Apply coupon'.
File
- modules/
promotion/ tests/ src/ FunctionalJavascript/ CouponRedemptionPaneTest.php, line 298
Class
- CouponRedemptionPaneTest
- Tests the coupon redemption checkout pane.
Namespace
Drupal\Tests\commerce_promotion\FunctionalJavascriptCode
public function testCheckoutWithMainSubmit() {
$coupons = $this->promotion
->getCoupons();
$coupon = reset($coupons);
$this
->drupalGet(Url::fromRoute('commerce_checkout.form', [
'commerce_order' => $this->cart
->id(),
]));
$this
->getSession()
->getPage()
->fillField('Coupon code', $coupon
->getCode());
$this
->submitForm([], 'Continue to review');
$this
->assertSession()
->pageTextContains('Visa ending in 9999');
$this
->assertSession()
->pageTextContains($coupon
->getCode());
$this
->assertSession()
->pageTextContains('-$99.90');
$this
->assertSession()
->pageTextContains('$899.10');
$this
->submitForm([], 'Pay and complete purchase');
$this
->assertSession()
->pageTextContains('Your order number is 1. You can view your order on your account page when logged in.');
$order_storage = $this->container
->get('entity_type.manager')
->getStorage('commerce_order');
$order_storage
->resetCache([
$this->cart
->id(),
]);
$this->cart = $order_storage
->load($this->cart
->id());
$this
->assertEquals(new Price('899.10', 'USD'), $this->cart
->getTotalPrice());
}