You are here

public function AjaxAddCartViewsRemoveButtonTest::testAjaxRemoveButton in Commerce Ajax Add to Cart 8

Tests whether the remove button views field is indeed ajaxified.

File

modules/dc_ajax_add_cart_views/tests/src/FunctionalJavascript/AjaxAddCartViewsRemoveButtonTest.php, line 67

Class

AjaxAddCartViewsRemoveButtonTest
Commerce Ajax Add to Cart Views Remove Button tests.

Namespace

Drupal\Tests\dc_ajax_add_cart_views\FunctionalJavascript

Code

public function testAjaxRemoveButton() {
  $this
    ->drupalLogin($this->account);
  foreach ($this->variations as $variation) {
    $this->cartManager
      ->addEntity($this->cart, $variation);
  }
  $cart_variation = $this
    ->getRandomVariation();
  $this
    ->drupalGet("cart-ajax/{$this->cart->id()}");
  $this
    ->assertCartAjaxPage();
  $variation_row_element = $this
    ->getRowCartAjaxByVariation($cart_variation);
  $this
    ->assertVariationRowCartAjax($variation_row_element);
  $variation_row_element
    ->findButton('Remove')
    ->click();
  $this
    ->assertVariationRowCartAjax($variation_row_element);
  $this->cart = Order::load($this->cart
    ->id());
  $order_items = $this->cart
    ->getItems();
  $this
    ->assertVariationInOrder($cart_variation, $order_items);
}