Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertMapOnProductView.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Cms\Test\Page\CmsIndex;
10 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 use Magento\Mtf\Fixture\InjectableFixture;
14 use Magento\Catalog\Test\Page\Product\CatalogProductView;
15 
19 class AssertMapOnProductView extends AbstractConstraint
20 {
30  public function processAssert(
31  CmsIndex $cmsIndex,
32  CatalogCategoryView $catalogCategoryView,
33  CatalogProductView $catalogProductView,
34  InjectableFixture $product
35  ) {
37  $cmsIndex->open();
38  $cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
39  $catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
40 
41  $viewBlock = $catalogProductView->getMsrpViewBlock();
42  $viewBlock->openMapBlock();
43  $mapBlock = $viewBlock->getMapBlock();
44  \PHPUnit\Framework\Assert::assertContains(
45  $product->getMsrp(),
46  $mapBlock->getOldPrice(),
47  'Displayed on Product view page MAP is incorrect.'
48  );
49  $priceData = $product->getDataFieldConfig('price')['source']->getPriceData();
50  $price = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice();
51  \PHPUnit\Framework\Assert::assertEquals(
52  $price,
53  $mapBlock->getActualPrice(),
54  'Displayed on Product view page price is incorrect.'
55  );
56  }
57 
63  public function toString()
64  {
65  return "Displayed Product MAP data on product view page is correct.";
66  }
67 }
$price