/** * 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.'); }
/** * Assert prices on the product view Page * * @param CatalogProductConfigurable $configurable * @param CatalogProductView $catalogProductView * @return void */ protected function assertOnProductView(CatalogProductConfigurable $configurable, CatalogProductView $catalogProductView) { /** @var \Magento\ConfigurableProduct\Test\Fixture\CatalogProductConfigurable\Price $priceFixture */ $priceFixture = $configurable->getDataFieldConfig('price')['source']; $pricePresetData = $priceFixture->getPreset(); if (isset($pricePresetData['product_special_price'])) { $regularPrice = $catalogProductView->getViewBlock()->getProductPriceBlock()->getRegularPrice(); \PHPUnit_Framework_Assert::assertEquals($pricePresetData['product_price'], $regularPrice, 'Product regular price on product view page is not correct.'); $specialPrice = $catalogProductView->getViewBlock()->getProductPriceBlock()->getSpecialPrice(); \PHPUnit_Framework_Assert::assertEquals($pricePresetData['product_special_price'], $specialPrice, 'Product special price on product view page is not correct.'); } else { //Price verification $price = $catalogProductView->getViewBlock()->getProductPriceBlock($configurable->getName())->getPrice(); \PHPUnit_Framework_Assert::assertEquals($price['price_regular_price'], $pricePresetData['product_price'], 'Product price on category page is not correct.'); } }