Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertBundleInCategory.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
13 use Magento\Mtf\Fixture\FixtureInterface;
14 
19 {
27  protected function assertPrice(FixtureInterface $bundle, CatalogCategoryView $catalogCategoryView)
28  {
30  $priceData = $bundle->getDataFieldConfig('price')['source']->getPriceData();
31  //Price from/to verification
32  $priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($bundle)->getPriceBlock();
33 
34  if ($bundle->hasData('special_price')) {
35  $priceLow = $priceBlock->getPrice();
36  } else {
37  $priceLow = ($bundle->getPriceView() == 'Price Range')
38  ? $priceBlock->getPriceFrom()
39  : $priceBlock->getPrice();
40  }
41 
42  \PHPUnit\Framework\Assert::assertEquals(
43  $priceData['price_from'],
44  $priceLow,
45  'Bundle price From on category page is not correct.'
46  );
47  if ($bundle->getPriceView() == 'Price Range') {
48  \PHPUnit\Framework\Assert::assertEquals(
49  $priceData['price_to'],
50  $priceBlock->getPriceTo(),
51  'Bundle price To on category page is not correct.'
52  );
53  }
54  }
55 
61  public function toString()
62  {
63  return 'Bundle price on category page is not correct.';
64  }
65 }
assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)