You are here

public function AjaxAddCartTest::testAjaxAddCartForm in Commerce Ajax Add to Cart 8

Tests whether the add to cart form is indeed ajaxified.

File

tests/src/FunctionalJavascript/AjaxAddCartTest.php, line 52

Class

AjaxAddCartTest
Ajax add cart tests.

Namespace

Drupal\Tests\dc_ajax_add_cart\FunctionalJavascript

Code

public function testAjaxAddCartForm() {
  $this
    ->drupalGet("product/{$this->variation->getProduct()->id()}");
  $ajax_add_cart_button = $this
    ->getSession()
    ->getPage()
    ->findButton('Add to cart');
  $ajax_add_cart_button
    ->click();
  $this->cart = Order::load($this->cart
    ->id());
  $order_items = $this->cart
    ->getItems();
  $this
    ->assertEmpty($order_items, 'Order items found in the cart');
}