Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertConfigurableProductInCategory.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
12 use Magento\Mtf\Fixture\FixtureInterface;
13 
18 {
26  protected function assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)
27  {
28  $priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock();
29  $priceData = $product->getDataFieldConfig('price')['source']->getPriceData();
30  $price = isset($priceData['category_price']) ? $priceData['category_price'] : $product->getPrice();
31  \PHPUnit\Framework\Assert::assertEquals(
32  number_format($price, 2, '.', ''),
33  $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(),
34  'Product regular price on category page is not correct.'
35  );
36 
37  if ($product->hasData('special_price')) {
38  \PHPUnit\Framework\Assert::assertEquals(
39  number_format($product->getSpecialPrice(), 2, '.', ''),
40  $priceBlock->getSpecialPrice(),
41  'Product special price on category page is not correct.'
42  );
43  }
44  }
45 }
assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)
$price