public function AjaxAddCartConfirmationMessageTest::testConfirmationMessage in Commerce Ajax Add to Cart 8
Tests whether the confirmation message appears after product added to cart.
File
- tests/
src/ FunctionalJavascript/ AjaxAddCartConfirmationMessageTest.php, line 33
Class
- AjaxAddCartConfirmationMessageTest
- Ajax add cart confirmation message tests.
Namespace
Drupal\Tests\dc_ajax_add_cart\FunctionalJavascriptCode
public function testConfirmationMessage() {
$this
->drupalGet("product/{$this->variation->getProduct()->id()}");
$ajax_add_cart_button = $this
->getSession()
->getPage()
->findButton('Add to cart');
$ajax_add_cart_button
->click();
$this
->waitForAjaxToFinish();
/*
* Confirm that the initial add to cart submit works.
*/
$this->cart = Order::load($this->cart
->id());
$order_items = $this->cart
->getItems();
$this
->assertOrderItemInOrder($this->variation, $order_items[0]);
// Confirm that the confirmation message has appeared.
$this
->assertSession()
->pageTextContains("{$this->variation->getProduct()->label()} added to your cart.", 'Confirmation message not found.');
}