You are here

protected function CartBrowserTestTrait::assertOrderItemInOrder in Commerce Core 8.2

Assert the order item in the order is correct.

Parameters

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

\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.

string $quantity: The quantity.

5 calls to CartBrowserTestTrait::assertOrderItemInOrder()
AddToCartFormTest::testExposedOrderItemFields in modules/cart/tests/src/Functional/AddToCartFormTest.php
Tests ability to expose order item fields on the add to cart form.
AddToCartFormTest::testProductAddToCartForm in modules/cart/tests/src/Functional/AddToCartFormTest.php
Test adding a product to the cart.
AddToCartMultiAttributeTest::testMultipleVariations in modules/cart/tests/src/FunctionalJavascript/AddToCartMultiAttributeTest.php
Tests adding a product to the cart when there are multiple variations.
AddToCartMultilingualTest::testProductVariationAttributesWidget in modules/cart/tests/src/FunctionalJavascript/AddToCartMultilingualTest.php
Tests that the attribute widget uses translated items.
AddToCartMultilingualTest::testProductVariationTitleWidget in modules/cart/tests/src/FunctionalJavascript/AddToCartMultilingualTest.php
Tests the title widget has translated variation title.

File

modules/cart/tests/src/Traits/CartBrowserTestTrait.php, line 78

Class

CartBrowserTestTrait
Defines a trait for commerce_cart functional tests.

Namespace

Drupal\Tests\commerce_cart\Traits

Code

protected function assertOrderItemInOrder(ProductVariationInterface $variation, OrderItemInterface $order_item, $quantity = '1') {
  $this
    ->assertEquals($order_item
    ->getTitle(), $variation
    ->getOrderItemTitle());
  $this
    ->assertNotEmpty($order_item
    ->getQuantity() == $quantity, t('The product @product has been added to cart with quantity of @quantity.', [
    '@product' => $order_item
      ->getTitle(),
    '@quantity' => $order_item
      ->getQuantity(),
  ]));
}