Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCurrencyRateAppliedOnCatalogPage.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Cms\Test\Page\CmsIndex;
10 use Magento\Mtf\Constraint\AbstractConstraint;
12 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
13 use Magento\CurrencySymbol\Test\Fixture\CurrencySymbolEntity;
14 
18 class AssertCurrencyRateAppliedOnCatalogPage extends AbstractConstraint
19 {
31  public function processAssert(
32  CmsIndex $cmsIndex,
33  CatalogCategoryView $catalogCategoryView,
34  CatalogProductSimple $product,
35  CurrencySymbolEntity $currencySymbol,
36  $basePrice,
37  $convertedPrice
38  ) {
39  $categoryName = $product->getCategoryIds()[0];
40  $cmsIndex->open();
41  $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
42  $priceBlock = $catalogCategoryView->getListProductBlock()->getProductItem($product)->getPriceBlock();
43  $actualPrice = $priceBlock->getPrice('');
44 
45  \PHPUnit\Framework\Assert::assertEquals(
46  $basePrice,
47  $actualPrice,
48  'Wrong price is displayed on Category page.'
49  );
50 
51  $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
52  $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
53  $actualPrice = $priceBlock->getPrice('');
54 
55  \PHPUnit\Framework\Assert::assertEquals(
56  $convertedPrice,
57  $actualPrice,
58  'Wrong price is displayed on Category page.'
59  );
60  }
61 
67  public function toString()
68  {
69  return "Currency rate has been applied correctly on Catalog page.";
70  }
71 }
$currencySymbol
Definition: matrix.phtml:14
processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CurrencySymbolEntity $currencySymbol, $basePrice, $convertedPrice)