/** * Select shipping method. * * @return void */ public function run() { if ($this->shipping['shipping_service'] !== '-') { $this->checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($this->shipping); $this->checkoutOnepage->getShippingMethodBlock()->clickContinue(); } }
/** * 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."); } }
/** * Run step that selecting payment method. * * @return array */ public function run() { if ($this->payment['method'] !== 'free') { $this->checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod($this->payment); } $this->checkoutOnepage->getPaymentMethodsBlock()->clickContinue(); return ['payment' => $this->payment]; }
/** * 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); }
/** * 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(); }
/** * 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()]; }
/** * Run step that selecting checkout method. * * @return void * @throws \Exception */ public function run() { $checkoutMethodBlock = $this->checkoutOnepage->getLoginBlock(); switch ($this->checkoutMethod) { case 'guest': $checkoutMethodBlock->guestCheckout(); $checkoutMethodBlock->clickContinue(); break; case 'register': $checkoutMethodBlock->registerCustomer(); $checkoutMethodBlock->clickContinue(); break; case 'login': $checkoutMethodBlock->loginCustomer($this->customer); break; default: throw new \Exception("Undefined checkout method."); break; } }
/** * Fill credit card step. * * @return void */ public function run() { $this->checkoutOnepage->getAuthorizenetDirectpostForm()->fill($this->payment['cc']); }
/** * Add gift message to order. * * @return array */ public function run() { $this->checkoutOnepage->getGiftMessagesBlock()->fillGiftMessage($this->giftMessage, $this->products); return ['giftMessage' => $this->giftMessage]; }
/** * Fill billing address. * * @return void */ public function run() { $this->checkoutOnepage->getBillingBlock()->fillBilling($this->billingAddress, $this->customer); $this->checkoutOnepage->getBillingBlock()->clickContinue(); }
/** * Select reward points. * * @return void */ public function run() { if (isset($this->payment['use_reward_points'])) { $this->checkoutOnepage->getRewardPointsBlock()->fillReward($this->payment); } }
/** * Get review totals. * * @return array */ public function getReviewTotals() { $totalBlock = $this->checkoutOnepage->getReviewBlock()->getTotalBlock(); return $this->getTypeBlockData($totalBlock); }
/** * Fill 3D secure credit card validation. * * @return void */ public function run() { $centinelForm = $this->checkoutOnepage->getReviewBlock()->getCentinelForm(); $centinelForm->fillCc($this->cc); $centinelForm->submitCode(); }
/** * 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()); }
/** * Select store credit. * * @return void */ public function run() { if (isset($this->payment['use_customer_balance'])) { $this->checkoutOnepage->getStoreCreditBlock()->fillStoreCredit($this->payment); } }