/** * Assert prices on the shopping Cart * * @param CatalogProductConfigurable $configurable * @param CheckoutCart $checkoutCart * @return void */ protected function assertOnShoppingCart(CatalogProductConfigurable $configurable, CheckoutCart $checkoutCart) { /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ $priceFixture = $configurable->getDataFieldConfig('price')['source']; $pricePresetData = $priceFixture->getPreset(); $price = $checkoutCart->getCartBlock()->getProductPriceByName($configurable->getName()); \PHPUnit_Framework_Assert::assertEquals($pricePresetData['cart_price'], $price, 'Product price in shopping cart is not correct.'); }
/** * Verify product price on category view page * * @param CatalogProductConfigurable $configurable * @param CatalogCategoryView $catalogCategoryView * @return void */ protected function assertPrice(CatalogProductConfigurable $configurable, CatalogCategoryView $catalogCategoryView) { /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ $priceFixture = $configurable->getDataFieldConfig('price')['source']; $pricePresetData = $priceFixture->getPreset(); //Regular price verification if (isset($pricePresetData['category_special_price'])) { $regularPrice = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($configurable->getName())->getRegularPrice(); \PHPUnit_Framework_Assert::assertEquals($pricePresetData['category_price'], $regularPrice, 'Product regular price on category page is not correct.'); //Special price verification $specialPrice = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($configurable->getName())->getSpecialPrice(); \PHPUnit_Framework_Assert::assertEquals($pricePresetData['category_special_price'], $specialPrice, 'Product special price on category page is not correct.'); } else { //Price verification $price = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($configurable->getName())->getPrice(); \PHPUnit_Framework_Assert::assertEquals($price['price_regular_price'], $pricePresetData['category_price'], 'Product price on category page is not correct.'); } }