You are here

protected function AjaxAddCartViewsTestBase::assertVariationInOrder in Commerce Ajax Add to Cart 8

Asserts whether the variation is present in order items.

Parameters

\Drupal\commerce_product\Entity\ProductVariationInterface $variation: The purchased product variation.

\Drupal\commerce_order\Entity\OrderItemInterface[] $order_items: The order items.

int $quantity: (Optional) The quantity for an additional check.

4 calls to AjaxAddCartViewsTestBase::assertVariationInOrder()
AjaxAddCartViewsEditQuantityTest::testAjaxUpdateCartButton in modules/dc_ajax_add_cart_views/tests/src/FunctionalJavascript/AjaxAddCartViewsEditQuantityTest.php
Tests whether the update cart button is indeed ajaxified.
AjaxAddCartViewsEditQuantityTest::testUpdateCartButton in modules/dc_ajax_add_cart_views/tests/src/FunctionalJavascript/AjaxAddCartViewsEditQuantityTest.php
Tests edit quantity views field.
AjaxAddCartViewsRemoveButtonTest::testAjaxRemoveButton in modules/dc_ajax_add_cart_views/tests/src/FunctionalJavascript/AjaxAddCartViewsRemoveButtonTest.php
Tests whether the remove button views field is indeed ajaxified.
AjaxAddCartViewsRemoveButtonTest::testRemoveButton in modules/dc_ajax_add_cart_views/tests/src/FunctionalJavascript/AjaxAddCartViewsRemoveButtonTest.php
Tests remove button views field.

File

modules/dc_ajax_add_cart_views/tests/src/Functional/AjaxAddCartViewsTestBase.php, line 132

Class

AjaxAddCartViewsTestBase
Base class for ajax add cart views tests.

Namespace

Drupal\Tests\dc_ajax_add_cart_views\Functional

Code

protected function assertVariationInOrder(ProductVariationInterface $variation, array $order_items, $quantity = 1) {
  $is_present = FALSE;
  foreach ($order_items as $item) {
    if ($item
      ->getPurchasedEntity()
      ->id() === $variation
      ->id() && $item
      ->getQuantity() == $quantity) {
      $is_present = TRUE;
    }
  }
  $this
    ->assertTrue($is_present, 'Variation not present in cart.');
}