10 use Magento\Catalog\Test\Page\Product\CatalogProductView;
11 use Magento\Checkout\Test\Page\CheckoutCart;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
14 use Magento\Mtf\Fixture\FixtureInterface;
52 CatalogProductView $catalogProductView,
54 BrowserInterface $browser,
58 $browser->open($_ENV[
'app_frontend_url'] .
$product->getUrlKey() .
'.html');
59 $catalogProductView->getViewBlock()->fillOptions(
$product);
60 $catalogProductView->getViewBlock()->clickAddToCart();
61 $catalogProductView->getMessagesBlock()->waitSuccessMessage();
64 $this->countPrices(
$product, $checkoutCart);
65 \PHPUnit\Framework\Assert::assertEquals(
66 $this->fixtureActualPrice,
68 'Product price in shopping cart is not correct.' 82 $this->fixturePrice =
$product->getPrice();
85 $this->countCheckoutCartItemPrice(
$product);
86 $this->countCustomOptionsPrice(
$product);
95 protected function countSpecialPrice(FixtureInterface
$product)
98 $specialPrice =
$product->getSpecialPrice();
100 $this->fixturePrice =
$product->getSpecialPrice();
113 $checkoutCart->open();
115 $this->formPrice =
$cartItem->getPrice();
124 protected function countCheckoutCartItemPrice(FixtureInterface
$product)
127 $checkoutData =
$product->getCheckoutData();
128 $checkoutCartItem = isset($checkoutData[
'cartItem']) ? $checkoutData[
'cartItem'] : [];
129 if (isset($checkoutCartItem[
'price'])) {
130 $this->fixturePrice = $checkoutCartItem[
'price'];
141 protected function countCustomOptionsPrice(FixtureInterface
$product)
145 $checkoutData =
$product->getCheckoutData();
146 $checkoutCustomOptions = isset($checkoutData[
'options'][
'custom_options'])
147 ? $checkoutData[
'options'][
'custom_options']
149 foreach ($checkoutCustomOptions as $checkoutOption) {
150 $attributeKey = str_replace(
'attribute_key_',
'', $checkoutOption[
'title']);
151 $optionKey = str_replace(
'option_key_',
'', $checkoutOption[
'value']);
154 if (
'Fixed' ==
$option[
'price_type']) {
155 $this->fixtureActualPrice +=
$option[
'price'];
157 $this->fixtureActualPrice += ($this->fixturePrice / 100) *
$option[
'price'];
169 return 'Product is correctly displayed in cart.';
processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, BrowserInterface $browser, CheckoutCart $checkoutCart)
prepareFormPrice(FixtureInterface $product, CheckoutCart $checkoutCart)