/**
  * Place order after checking order totals on review step.
  *
  * @return array
  */
 public function run()
 {
     $reviewBlock = $this->checkoutOnepage->getReviewBlock();
     if ($this->hasAlert) {
         return ['alertText' => $reviewBlock->handleSubmittingOrderInformation()];
     } else {
         $reviewBlock->clickContinue();
         return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()];
     }
 }
 /**
  * Check that checkbox is present on the last checkout step - Order Review.
  * Check that after Place order without click on checkbox "Terms and Conditions" order was not successfully placed.
  * Check that after clicking on "Terms and Conditions" checkbox and "Place Order" button success place order message
  * appears.
  *
  * @param ObjectManager $objectManager
  * @param Address $billingAddress
  * @param CheckoutOnepage $checkoutOnepage
  * @param CheckoutOnepageSuccess $checkoutOnepageSuccess
  * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage
  * @param CheckoutAgreement $checkoutAgreement
  * @param string $checkoutMethod
  * @param string $products
  * @param array $shipping
  * @param array $payment
  * @return void
  */
 public function processAssert(ObjectManager $objectManager, Address $billingAddress, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, CheckoutAgreement $checkoutAgreement, $checkoutMethod, $products, array $shipping, array $payment)
 {
     $this->objectManager = $objectManager;
     $products = $this->createProducts($products);
     $this->addToCart($products);
     $this->startCheckout();
     $this->processCheckout($checkoutMethod, $billingAddress, $shipping, $payment);
     $alertText = $checkoutOnepage->getReviewBlock()->clickContinue();
     \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $alertText, 'Notification required message of Terms and Conditions is absent.');
     $checkoutOnepage->getReviewBlock()->setAgreement($checkoutAgreement, 'Yes');
     $checkoutOnepage->getReviewBlock()->clickContinue();
     $assertOrderSuccessPlacedMessage->processAssert($checkoutOnepageSuccess);
 }
 /**
  * Place order after checking order totals on review step.
  *
  * @return mixed
  */
 public function run()
 {
     $orderId = null;
     if ($this->positiveCase) {
         $this->checkoutOnepage->getReviewBlock()->clickContinue();
         $orderId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
     }
     return ['orderId' => $orderId, 'order' => $this->createOrderFixture($orderId)];
 }
 /**
  * Fill credit card in i-frame step.
  *
  * @return array
  */
 public function run()
 {
     $this->checkoutOnepage->getReviewBlock()->clickContinue();
     $this->browser->switchToFrame(new Locator($this->iFrameSelector));
     $methodName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $this->payment['method']))) . 'Form';
     $form = $this->checkoutOnepage->{$methodName}();
     $element = $this->browser->find('body');
     $form->fill($this->payment['cc'], $element);
     $form->clickPayNow($element);
     return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()];
 }
 /**
  * Assert that 3D secure verification failed.
  *
  * @param CheckoutOnepage $checkoutOnepage
  * @return void
  */
 public function processAssert(CheckoutOnepage $checkoutOnepage)
 {
     \PHPUnit_Framework_Assert::assertContains(self::VERIFICATION_FAIL_MESSAGE, $checkoutOnepage->getReviewBlock()->getVerificationResponseText());
 }
 /**
  * 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.");
     }
 }
 /**
  * Fill 3D secure credit card validation.
  *
  * @return void
  */
 public function run()
 {
     $centinelForm = $this->checkoutOnepage->getReviewBlock()->getCentinelForm();
     $centinelForm->fillCc($this->cc);
     $centinelForm->submitCode();
 }
 /**
  * Get review totals.
  *
  * @return array
  */
 public function getReviewTotals()
 {
     $totalBlock = $this->checkoutOnepage->getReviewBlock()->getTotalBlock();
     return $this->getTypeBlockData($totalBlock);
 }