/**
  * Assert prices on the shopping cart.
  *
  * @param InjectableFixture $product
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 protected function assertOnShoppingCart(InjectableFixture $product, CheckoutCart $checkoutCart)
 {
     $cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
     $formPrice = $cartItem->getCartItemTypePrice('price');
     $fixturePrice = number_format($this->prepareFixturePrice($product), 2);
     \PHPUnit_Framework_Assert::assertEquals($fixturePrice, $formPrice, 'Product price in shopping cart is not correct.');
 }
 /**
  * Assert that products are present in shopping cart.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $products
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, array $products)
 {
     $checkoutCart->open();
     foreach ($products as $product) {
         \PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCartBlock()->getCartItem($product)->isVisible(), "Product '{$product->getName()}' is absent in shopping cart.");
     }
 }
 /**
  * Assert that products' MAP has been applied before checkout.
  *
  * @param CatalogCategory $category
  * @param Customer $customer
  * @param Address $address
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $cart
  * @param CheckoutOnepage $checkoutOnePage
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogCategory $category, Customer $customer, Address $address, CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, CheckoutCart $cart, CheckoutOnepage $checkoutOnePage, array $products)
 {
     for ($i = 0; $i < count($products); $i++) {
         $cart->getCartBlock()->clearShoppingCart();
         $productName = $products[$i]->getName();
         $cmsIndex->open();
         $cmsIndex->getTopmenu()->selectCategory($category->getName());
         // Check that price is not present on category page.
         $listProductBlock = $catalogCategoryView->getListProductBlock();
         $productPriceBlock = $listProductBlock->getProductPriceBlock($productName);
         $productPriceBlock->clickForPrice();
         \PHPUnit_Framework_Assert::assertFalse($productPriceBlock->getMapBlock()->isPriceVisible(), 'Price is present in MSRP dialog on category page.');
         // Check that price is not present on product page.
         $listProductBlock->openProductViewPage($productName);
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->getPriceBlock()->isRegularPriceVisible(), 'Price is present in View block on product page.');
         // Check that price is not present on cart.
         $catalogProductView->getViewBlock()->addToCart($products[$i]);
         \PHPUnit_Framework_Assert::assertTrue($cart->getCartBlock()->getCartItem($products[$i])->isMsrpVisible(), "MSRP link is not visible in cart.");
         // Check that price is present on review block in onepage checkout page.
         $cart->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout();
         $checkoutMethodBlock = $checkoutOnePage->getLoginBlock();
         $billingBlock = $checkoutOnePage->getBillingBlock();
         $paymentMethodBlock = $checkoutOnePage->getPaymentMethodsBlock();
         $shippingBlock = $checkoutOnePage->getShippingMethodBlock();
         $checkoutMethodBlock->guestCheckout();
         $checkoutMethodBlock->clickContinue();
         $billingBlock->fillBilling($address, $customer);
         $billingBlock->clickContinue();
         $shippingBlock->selectShippingMethod(['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed']);
         $shippingBlock->clickContinue();
         $paymentMethodBlock->selectPaymentMethod(['method' => 'checkmo']);
         $paymentMethodBlock->clickContinue();
         \PHPUnit_Framework_Assert::assertEquals(number_format($products[$i]->getPrice(), 2), $checkoutOnePage->getReviewBlock()->getTotalBlock()->getData('subtotal'), "Subtotal in checkout one page for {$productName} is not equal to expected.");
     }
 }
 /**
  * Assert prices on the product view page and shopping cart page.
  *
  * @param CheckoutCart $checkoutCartView
  * @return void
  */
 protected function assertPrice(CheckoutCart $checkoutCartView)
 {
     $formCartItem = $checkoutCartView->getCartBlock()->getCartItem($this->product);
     $fixtureCartItem = $this->product->getCheckoutData()['cartItem'];
     $this->assertCartOptions($fixtureCartItem['options']['bundle_options'], $formCartItem->getOptions());
     $this->assertCartPrice($fixtureCartItem['price'], $formCartItem->getCartItemTypePrice('price'));
 }
 /**
  * Assert that grand total is equal to expected.
  *
  * @param CheckoutCart $checkoutCart
  * @param Cart $cart
  * @param Customer|null $customer
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, Cart $cart, Customer $customer = null)
 {
     if ($customer !== null) {
         $this->login($customer);
     }
     $checkoutCart->open();
     \PHPUnit_Framework_Assert::assertEquals(number_format($cart->getGrandTotal(), 2), $checkoutCart->getTotalsBlock()->getData('grand_total'));
 }
 /**
  * Assertion that the product is correctly displayed in cart.
  *
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture $product
  * @param Browser $browser
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, InjectableFixture $product, Browser $browser, CheckoutCart $checkoutCart)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutData = $product->getCheckoutData();
     $price = $checkoutCart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price');
     \PHPUnit_Framework_Assert::assertEquals($checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.');
 }
 /**
  * Assert that gift card usable in frontend.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param Browser $browser
  * @param string $code
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CatalogProductSimple $product, Browser $browser, $code)
 {
     $this->checkoutCart = $checkoutCart;
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCart();
     $checkoutCart->getGiftCardAccountBlock()->addGiftCard($code);
     $this->assert();
 }
 /**
  * Apply gift card before one page checkout.
  *
  * @return void
  */
 public function run()
 {
     foreach ($this->giftCardAccounts as $giftCardAccount) {
         if ($giftCardAccount !== null) {
             $this->checkoutCart->getGiftCardAccountBlock()->addGiftCard($giftCardAccount->getCode());
         }
     }
 }
 /**
  * Assert that product can be configured and added to cart after added this product to cart by sku.
  *
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductView $catalogProductView
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, CatalogProductView $catalogProductView, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $checkoutCart->open()->getAdvancedCheckoutCart()->clickSpecifyProductOptionsLink($product);
         $catalogProductView->getViewBlock()->addToCart($product);
         \PHPUnit_Framework_Assert::assertEquals(sprintf(self::SUCCESS_MESSAGE, $product->getName()), $checkoutCart->getMessagesBlock()->getSuccessMessages());
     }
 }
 /**
  * Assert that after adding products by sku, wrong requested quantity error message appears.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $currentMessage = $checkoutCart->getAdvancedCheckoutCart()->getFailedItemErrorMessage($product);
         \PHPUnit_Framework_Assert::assertContains(self::ERROR_QUANTITY_MESSAGE, $currentMessage);
         \PHPUnit_Framework_Assert::assertContains(sprintf($this->allowedQtyMessage, $product->getStockData()[$this->saleQtyType]), $currentMessage);
     }
 }
 /**
  * Assert that requested quantity is not available error message is displayed after adding products to cart by sku.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $currentMessage = $checkoutCart->getAdvancedCheckoutCart()->getFailedItemErrorMessage($product);
         \PHPUnit_Framework_Assert::assertContains(self::ERROR_QUANTITY_MESSAGE, $currentMessage);
         \PHPUnit_Framework_Assert::assertContains(sprintf(self::LEFT_IN_STOCK_ERROR_MESSAGE, $product->getStockData()['qty']), $currentMessage);
     }
 }
 /**
  * Assert that product can be added to active gift registry from shopping cart.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param InjectableFixture $product
  * @param GiftRegistry $giftRegistry
  * @param GiftRegistryItems $giftRegistryItems
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product, GiftRegistry $giftRegistry, GiftRegistryItems $giftRegistryItems, BrowserInterface $browser)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutCart->getGiftRegistryBlock()->addToGiftRegistry($giftRegistry);
     \PHPUnit_Framework_Assert::assertTrue($giftRegistryItems->getGiftRegistryItemsBlock()->isProductInGrid($product), "Product can not be added to active gift registry '{$giftRegistry->getTitle()}' from shopping cart.");
 }
 /**
  * Add products to the cart.
  *
  * @return void
  */
 public function run()
 {
     // Ensure that shopping cart is empty
     $this->checkoutCart->open()->getCartBlock()->clearShoppingCart();
     foreach ($this->products as $product) {
         $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
         $this->catalogProductView->getViewBlock()->addToCart($product);
     }
 }
 /**
  * Assert that Catalog Price Rule is applied for product(s) in Shopping Cart
  * according to Priority(Priority/Stop Further Rules Processing).
  *
  * @param InjectableFixture $product
  * @param CatalogProductView $pageCatalogProductView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CheckoutCart $pageCheckoutCart
  * @param array $prices
  * @return void
  */
 public function processAssert(InjectableFixture $product, CatalogProductView $pageCatalogProductView, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CheckoutCart $pageCheckoutCart, array $prices)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product->getName());
     $pageCatalogProductView->getViewBlock()->addToCart($product);
     $actualGrandTotal = $pageCheckoutCart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price');
     \PHPUnit_Framework_Assert::assertEquals($prices['grand_total'], $actualGrandTotal);
 }
 /**
  * Run Move from ShoppingCard to Wishlist test.
  *
  * @param Customer $customer
  * @param CheckoutCart $checkoutCart
  * @param string $product
  * @return array
  */
 public function test(Customer $customer, CheckoutCart $checkoutCart, $product)
 {
     // Preconditions:
     $product = $this->createProducts($product)[0];
     $this->loginCustomer($customer);
     // Steps:
     $this->addToCart($product);
     $checkoutCart->open()->getCartBlock()->getCartItem($product)->moveToWishlist();
     return ['product' => $product];
 }
 /**
  * Assert that created gift card account can be verified on the frontend in Shopping Cart.
  *
  * @param Customer $customer
  * @param Browser $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param GiftCardAccount $giftCardAccount
  * @param CheckoutCart $checkoutCart
  * @param string $code
  * @return void
  */
 public function processAssert(Customer $customer, Browser $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, GiftCardAccount $giftCardAccount, CheckoutCart $checkoutCart, $code)
 {
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCart();
     $data = $giftCardAccount->getData();
     $checkoutCart->getGiftCardAccountBlock()->checkStatusAndBalance($code);
     $fixtureData = ['code' => $code, 'balance' => $data['balance'], 'date_expires' => $data['date_expires']];
     \PHPUnit_Framework_Assert::assertEquals($fixtureData, $checkoutCart->getCheckBlock()->getGiftCardAccountData($fixtureData));
 }
 /**
  * Assert that banner is absent on Shopping Cart page.
  *
  * @param Browser $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param Banner $banner
  * @param CheckoutCart $checkoutCart
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(Browser $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, Banner $banner, CheckoutCart $checkoutCart, Cache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getBannerViewBlock()->checkWidgetBanners($banner), 'Banner is present on Shopping Cart page.');
 }
 /**
  * Assert that product is not displayed in cross-sell section.
  *
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param InjectableFixture[]|null $promotedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, array $promotedProducts = null)
 {
     if (!$promotedProducts) {
         $promotedProducts = $product->hasData('cross_sell_products') ? $product->getDataFieldConfig('cross_sell_products')['source']->getProducts() : [];
     }
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutCart->open();
     foreach ($promotedProducts as $promotedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->getItemBlock($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.');
     }
 }
 /**
  * Assert that product has tier price message appears after adding products by sku to shopping cart.
  *
  * @param CheckoutCart $checkoutCart
  * @param array $requiredAttentionProducts
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, array $requiredAttentionProducts)
 {
     foreach ($requiredAttentionProducts as $product) {
         $messages = $checkoutCart->getAdvancedCheckoutCart()->getTierPriceMessages($product);
         $tierPrices = $product->getTierPrice();
         \PHPUnit_Framework_Assert::assertTrue(count($messages) === count($tierPrices), 'Wrong qty messages is displayed.');
         foreach ($tierPrices as $key => $tierPrice) {
             $price = (bool) strpos($messages[$key], (string) $tierPrice['price']);
             $priceQty = (bool) strpos($messages[$key], (string) $tierPrice['price_qty']);
             $savePercent = (bool) strpos($messages[$key], $this->getSavePercent($product->getPrice(), $tierPrice));
             \PHPUnit_Framework_Assert::assertTrue($price and $priceQty and $savePercent, 'Wrong tier price message is displayed.');
         }
     }
 }
 /**
  * Assert that products are displayed in cross-sell section.
  *
  * @param Browser $browser
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture[] $crossSellProducts
  * @return void
  */
 public function processAssert(Browser $browser, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $crossSellProducts)
 {
     $checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $errors = [];
     $crosssellBlock = $checkoutCart->getCrosssellBlock();
     foreach ($crossSellProducts as $crossSellProduct) {
         if (!$crosssellBlock->getItemBlock($crossSellProduct)->isVisible()) {
             $errors[] = "Product {$crossSellProduct->getName()} is absent in cross-sell section.";
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }
 /**
  * Assert that Gift Wrapping can be found during one page checkout on frontend.
  *
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param BrowserInterface $browser
  * @param CheckoutOnepage $checkoutOnepage
  * @param GiftWrapping $giftWrapping
  * @param Address $billingAddress
  * @param CatalogProductSimple $product
  * @param Customer $customer
  * @param CustomerAccountLogout $customerAccountLogout
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, BrowserInterface $browser, CheckoutOnepage $checkoutOnepage, GiftWrapping $giftWrapping, Address $billingAddress, CatalogProductSimple $product, Customer $customer, CustomerAccountLogout $customerAccountLogout)
 {
     // Preconditions
     $customer->persist();
     $product->persist();
     // Steps
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutCart->open()->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout();
     $checkoutOnepage->getLoginBlock()->loginCustomer($customer);
     $checkoutOnepage->getBillingBlock()->fillBilling($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     \PHPUnit_Framework_Assert::assertContains($giftWrapping->getDesign(), $checkoutOnepage->getGiftOptionsBlock()->getGiftWrappingsAvailable(), "Gift Wrapping '{$giftWrapping->getDesign()}' is not present in one page checkout on frontend.");
     $customerAccountLogout->open();
 }
 /**
  * Remove products form cart.
  *
  * @param array $products
  * @return void
  */
 protected function removeProducts(array $products)
 {
     $this->cartPage->open();
     foreach ($products as $product) {
         $this->cartPage->getCartBlock()->getCartItem($product)->removeItem();
     }
 }
 /**
  * Update shopping cart.
  *
  * @param CatalogProductSimple $product
  * @return void
  */
 protected function updateShoppingCart(CatalogProductSimple $product)
 {
     $qty = $product->getCheckoutData()['qty'];
     $this->checkoutCart->open();
     $this->checkoutCart->getCartBlock()->getCartItem($product)->setQty($qty);
     $this->checkoutCart->getCartBlock()->updateShoppingCart();
 }
 /**
  * Get grand total.
  *
  * @return array
  */
 protected function getTotalPrice()
 {
     $prices = [];
     foreach ($this->expectedPrices['total'] as $key => $type) {
         $prices[$key] = $this->checkoutCart->getTotalsBlock()->getData($key);
     }
     return $prices;
 }
 /**
  * Assert that product is displayed in cross-sell section.
  *
  * @param BrowserInterface $browser
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture[]|null $promotedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $promotedProducts = null)
 {
     $errors = [];
     if (!$promotedProducts) {
         $promotedProducts = $product->hasData('cross_sell_products') ? $product->getDataFieldConfig('cross_sell_products')['source']->getProducts() : [];
     }
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $checkoutCart->open();
     foreach ($promotedProducts as $promotedProduct) {
         if (!$checkoutCart->getCrosssellBlock()->verifyProductCrosssell($promotedProduct)) {
             $errors[] = 'Product \'' . $promotedProduct->getName() . '\' is absent in cross-sell section.';
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }
 /**
  * Assert that products are displayed in related section.
  *
  * @param Browser $browser
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductView $catalogProductView
  * @param array $productsData
  * @param array $relatedProductsData
  * @return void
  */
 public function processAssert(Browser $browser, CheckoutCart $checkoutCart, CatalogProductView $catalogProductView, array $productsData, array $relatedProductsData)
 {
     $checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $index = $relatedProductsData['firstProduct']['productIndex'];
     $productCheck = $productsData[$index]['product'];
     $relatedProducts = $productsData[$index]['relatedProducts']['related_products']['value'];
     $browser->open($_ENV['app_frontend_url'] . $productCheck->getUrlKey() . '.html');
     $this->assertRelatedSection($catalogProductView, $relatedProducts);
     $index = $relatedProductsData['secondProduct']['productIndex'];
     $productCheck = $productsData[$index]['product'];
     $relatedProducts = $productsData[$index]['relatedProducts']['related_products']['value'];
     $this->openRelatedProduct($catalogProductView, $productCheck);
     $this->assertRelatedSection($catalogProductView, $relatedProducts);
     $index = $relatedProductsData['thirdProduct']['productIndex'];
     $productCheck = $productsData[$index]['product'];
     $this->openRelatedProduct($catalogProductView, $productCheck);
     $this->assertRelatedSectionAbsent($catalogProductView);
 }
 /**
  * Get totals from total block in shopping cart.
  *
  * @return array
  */
 protected function getTotals()
 {
     $totals = [];
     $totals['subtotal'] = $this->checkoutCart->getTotalsBlock()->getData('subtotal');
     $totals['grandTotal'] = $this->checkoutCart->getTotalsBlock()->getData('grand_total');
     if ($this->checkoutCart->getTotalsBlock()->isVisibleShippingPriceBlock()) {
         $shippingPrice = $this->checkoutCart->getTotalsBlock()->getData('shipping_price');
         $totals['grandTotal'] = number_format($totals['grandTotal'] - $shippingPrice, 2);
     }
     return $totals;
 }
 /**
  * Assert that product products' MAP has been applied in cart.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param CmsIndex $cmsIndex
  * @param CatalogCategory $category
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $cart
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogCategory $category, CatalogProductView $catalogProductView, CheckoutCart $cart, array $products)
 {
     foreach ($products as $product) {
         $cart->getCartBlock()->clearShoppingCart();
         $productName = $product->getName();
         $cmsIndex->open();
         $cmsIndex->getTopmenu()->selectCategory($category->getName());
         $listProductBlock = $catalogCategoryView->getListProductBlock();
         // Check that price is not present on category page.
         $productPriceBlock = $listProductBlock->getProductPriceBlock($productName);
         $productPriceBlock->clickForPrice();
         \PHPUnit_Framework_Assert::assertFalse($productPriceBlock->getMapBlock()->isPriceVisible(), 'Price is present in MSRP dialog on category page.');
         // Check that price is not present on product page.
         $listProductBlock->openProductViewPage($productName);
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->getPriceBlock()->isRegularPriceVisible(), 'Price is present in View block on product page.');
         // Check that price is present in cart.
         $catalogProductView->getViewBlock()->addToCart($product);
         \PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $cart->getCartBlock()->getCartItem($product)->getCartItemTypePrice('price'), "MAP of {$productName} product in cart is not equal to product price.");
     }
 }
 /**
  * Add GiftCard in ShoppingCart.
  *
  * @param Customer $customerFixture
  * @param GiftCardAccount $giftCardAccount
  * @param BrowserInterface $browser
  * @param string $product
  * @param string|null $customer
  * @return array
  */
 public function test(Customer $customerFixture, GiftCardAccount $giftCardAccount, BrowserInterface $browser, $product, $customer = null)
 {
     // Preconditions
     $product = $this->createProduct($product);
     // Steps
     if ($customer !== null) {
         $this->loginCustomer($customerFixture);
     }
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $this->catalogProductView->getViewBlock()->addToCart($product);
     $this->checkoutCart->getGiftCardAccountBlock()->addGiftCard($giftCardAccount->getCode());
     return ['giftCardAccount' => $giftCardAccount];
 }
 /**
  * Assert that product is displayed in cross-sell section for customer segment.
  *
  * @param Browser $browser
  * @param Customer $customer
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param CustomerAccountLogout $customerAccountLogout
  * @param InjectableFixture[] $promotedProducts
  * @return void
  */
 public function processAssert(Browser $browser, Customer $customer, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, CustomerAccountLogout $customerAccountLogout, array $promotedProducts)
 {
     // Create customer, logout and login to frontend
     $customer->persist();
     $customerAccountLogout->open();
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     // Clear cart
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     // Check display cross sell products
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $errors = [];
     foreach ($promotedProducts as $promotedProduct) {
         if (!$checkoutCart->getCrosssellBlock()->getItemBlock($promotedProduct)->isVisible()) {
             $errors[] = "Product '{$promotedProduct->getName()}' is absent in cross-sell section.";
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }