public function AjaxAddCartViewsRemoveButtonTest::testOrderTotal in Commerce Ajax Add to Cart 8
Tests whether order total is correct on ajax removing product from cart.
File
- modules/
dc_ajax_add_cart_views/ tests/ src/ FunctionalJavascript/ AjaxAddCartViewsRemoveButtonTest.php, line 95
Class
- AjaxAddCartViewsRemoveButtonTest
- Commerce Ajax Add to Cart Views Remove Button tests.
Namespace
Drupal\Tests\dc_ajax_add_cart_views\FunctionalJavascriptCode
public function testOrderTotal() {
$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
->waitForAjaxToFinish();
$this->cart = Order::load($this->cart
->id());
$price = $this
->getSession()
->getPage()
->find('css', '.order-total-line__total .order-total-line-value')
->getText();
$price = (double) preg_replace('/[^0-9\\.]/', '', $price);
$actual_price = (double) $this->cart
->getTotalPrice()
->getNumber();
$this
->assertEquals($price, $actual_price, 'Prices are not equal.');
}