Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertPriceInShoppingCart.php
Go to the documentation of this file.
1 <?php
8 
12 use Magento\Checkout\Test\Page\CheckoutCart;
14 use Magento\Mtf\Fixture\FixtureInterface;
15 
21 {
29  public function processAssert(CheckoutCart $checkoutCart, Cart $cart)
30  {
31  $checkoutCart->open();
33  $sourceProducts = $cart->getDataFieldConfig('items')['source'];
34  $products = $sourceProducts->getProducts();
35  $items = $cart->getItems();
36  $productsData = [];
37  $cartData = [];
38 
39  foreach ($items as $key => $item) {
41  $product = $products[$key];
42  $productName = $product->getName();
44  $checkoutItem = $item->getData();
45  $cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
46 
47  $productsData[$productName] = [
48  'price' => $checkoutItem['price'],
49  ];
50  $cartData[$productName] = [
51  'price' => $cartItem->getPrice(),
52  ];
53  }
54 
55  $error = $this->verifyData($productsData, $cartData, true);
56  \PHPUnit\Framework\Assert::assertEmpty($error, $error);
57  }
58 
64  public function toString()
65  {
66  return 'Price in the shopping cart equals to expected price from data set.';
67  }
68 }
$productsData
Definition: products.php:19
verifyData(array $fixtureData, array $formData, $isStrict=false, $isPrepareError=true)
$items