Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertMsrpInShoppingCart.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Constraint\AbstractConstraint;
10 use Magento\Cms\Test\Page\CmsIndex;
11 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
12 use Magento\Catalog\Test\Page\Product\CatalogProductView;
13 use Magento\Mtf\Fixture\InjectableFixture;
15 use Magento\Checkout\Test\Page\CheckoutCart;
16 
20 class AssertMsrpInShoppingCart extends AbstractConstraint
21 {
32  public function processAssert(
33  CmsIndex $cmsIndex,
34  CatalogCategoryView $catalogCategoryView,
35  CatalogProductView $catalogProductView,
36  CheckoutCart $checkoutCart,
37  InjectableFixture $product
38  ) {
40  $cmsIndex->open();
41  $cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
42  $catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
43 
44  if ($product->hasData('checkout_data') || $product->getMsrpDisplayActualPriceType() === 'In Cart') {
45  $catalogProductView->getViewBlock()->addToCart($product);
46  } else {
47  $catalogProductView->getMsrpViewBlock()->openMapBlock();
48  $catalogProductView->getMsrpViewBlock()->getMapBlock()->addToCart();
49  }
50  $catalogProductView->getMessagesBlock()->waitSuccessMessage();
51 
52  $checkoutCart->open();
53 
54  $priceData = $product->getDataFieldConfig('price')['source']->getPriceData();
55  $productPrice = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice();
56  $unitPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
57  \PHPUnit\Framework\Assert::assertEquals($productPrice, $unitPrice, 'Incorrect unit price is displayed in Cart');
58  }
59 
65  public function toString()
66  {
67  return "Displayed Product MAP data in Shopping Cart is correct.";
68  }
69 }