/** * Assert that prices on order review and customer order pages are equal to specified in dataset. * * @param array $prices * @param InjectableFixture $product * @param CheckoutCart $checkoutCart * @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param CustomerOrderView $customerOrderView * @param CmsIndex $cmsIndex * @return void */ public function processAssert(array $prices, InjectableFixture $product, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, CustomerOrderView $customerOrderView, CmsIndex $cmsIndex) { $this->checkoutOnepage = $checkoutOnepage; $this->customerOrderView = $customerOrderView; $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout(); $cmsIndex->getCmsPageBlock()->waitPageInit(); $shippingMethod = ['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed']; $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shippingMethod); $checkoutOnepage->getShippingMethodBlock()->clickContinue(); $checkoutOnepage->getPaymentBlock()->selectPaymentMethod(['method' => 'checkmo']); $actualPrices = []; $actualPrices = $this->getReviewPrices($actualPrices, $product); $actualPrices = $this->getReviewTotals($actualPrices); $prices = $this->preparePrices($prices); //Order review prices verification $message = 'Prices on order review should be equal to defined in dataset.'; \PHPUnit_Framework_Assert::assertEquals(array_diff_key($prices, ['cart_item_price_excl_tax' => null, 'cart_item_price_incl_tax' => null]), $actualPrices, $message); $checkoutOnepage->getPaymentBlock()->placeOrder(); $checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); $checkoutOnepageSuccess->getSuccessBlock()->openOrder(); $actualPrices = []; $actualPrices = $this->getOrderPrices($actualPrices, $product); $actualPrices = $this->getOrderTotals($actualPrices); //Frontend order prices verification $message = 'Prices on order view page should be equal to defined in dataset.'; \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); }
/** * Place order after checking order totals on review step. * * @return array */ public function run() { if (isset($this->prices['grandTotal'])) { $this->assertGrandTotalOrderReview->processAssert($this->checkoutOnepage, $this->prices['grandTotal']); } $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()]; }
/** * Place order after checking order totals on review step. * * @return array */ public function run() { if (isset($this->prices['grandTotal'])) { $this->assertGrandTotalOrderReview->processAssert($this->checkoutOnepage, $this->prices['grandTotal']); } $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); $order = $this->fixtureFactory->createByCode('orderInjectable', ['data' => ['entity_id' => ['products' => $this->products]]]); return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), 'order' => $order]; }
/** * Fill billing address. * * @return void */ public function run() { if ($this->billingCheckboxState) { $this->assertBillingAddressCheckbox->processAssert($this->checkoutOnepage, $this->billingCheckboxState); } if ($this->billingAddress) { $selectedPaymentMethod = $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock(); $selectedPaymentMethod->getBillingBlock()->fillBilling($this->billingAddress); } }
/** * 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 FixtureFactory $fixtureFactory * @param ObjectManager $objectManager * @param string $product * @param BrowserInterface $browser * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage * @param array $shipping * @param array $payment * @return void * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, $shipping, $payment) { $createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]); $product = $createProductsStep->run(); $billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']); $browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->clickAddToCartButton(); $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout(); $checkoutOnepage->getLoginBlock()->clickContinue(); $checkoutOnepage->getBillingBlock()->fill($billingAddress); $checkoutOnepage->getBillingBlock()->clickContinue(); $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping); $checkoutOnepage->getShippingMethodBlock()->clickContinue(); $checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment); $checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $checkoutOnepage->getAgreementReview()->getNotificationMassage(), 'Notification required message of Terms and Conditions is absent.'); $checkoutOnepage->getAgreementReview()->setAgreement('Yes'); $checkoutOnepage->getAgreementReview()->placeOrder(); $assertOrderSuccessPlacedMessage->processAssert($checkoutOnepageSuccess); }
/** * Assert that prices on order review and customer order pages are equal to specified in dataset. * * @param array $prices * @param InjectableFixture $product * @param CheckoutCart $checkoutCart * @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param CustomerOrderView $customerOrderView * @return void */ public function processAssert(array $prices, InjectableFixture $product, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, CustomerOrderView $customerOrderView, CmsIndex $cmsIndex) { $this->checkoutOnepage = $checkoutOnepage; $this->customerOrderView = $customerOrderView; $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout(); $cmsIndex->getCmsPageBlock()->waitPageInit(); $checkoutOnepage->getPaymentBlock()->selectPaymentMethod(['method' => 'checkmo']); $actualPrices = []; $actualPrices = $this->getReviewPrices($actualPrices, $product); $actualPrices = $this->getReviewTotals($actualPrices); $prices = $this->preparePrices($prices); //Order review prices verification $message = 'Prices on order review should be equal to defined in dataset.'; \PHPUnit_Framework_Assert::assertEquals($prices, array_filter($actualPrices), $message); $checkoutOnepage->getPaymentBlock()->placeOrder(); $checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); $checkoutOnepageSuccess->getSuccessBlock()->openOrder(); $actualPrices = []; $actualPrices = $this->getOrderPrices($actualPrices, $product); $actualPrices = $this->getOrderTotals($actualPrices); //Frontend order prices verification $message = 'Prices on order view page should be equal to defined in dataset.'; \PHPUnit_Framework_Assert::assertEquals($prices, array_filter($actualPrices), $message); }
/** * Place order and verify there is no checkbox Terms and Conditions. * * @param FixtureFactory $fixtureFactory * @param ObjectManager $objectManager * @param string $product * @param BrowserInterface $browser * @param CatalogProductView $catalogProductView * @param CheckoutCart $checkoutCart * @param CheckoutOnepage $checkoutOnepage * @param CheckoutAgreement $agreement * @param array $shipping * @param array $payment * @return void * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutAgreement $agreement, $shipping, $payment) { $createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]); $product = $createProductsStep->run(); $billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']); $browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->clickAddToCartButton(); $catalogProductView->getMessagesBlock()->waitSuccessMessage(); $checkoutCart->open(); $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout(); $checkoutOnepage->getLoginBlock()->clickContinue(); $checkoutOnepage->getBillingBlock()->fill($billingAddress); $checkoutOnepage->getBillingBlock()->clickContinue(); $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping); $checkoutOnepage->getShippingMethodBlock()->clickContinue(); $checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment); \PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.'); }
/** * 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 string $products * @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage * @param array $shipping * @param array $payment * @param CheckoutAgreement $agreement * @return void */ public function processAssert(ObjectManager $objectManager, $products, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, AssertOrderSuccessPlacedMessage $assertOrderSuccessPlacedMessage, $shipping, $payment, CheckoutAgreement $agreement) { $paymentBlock = $checkoutOnepage->getPaymentBlock(); $shippingAddressData = ['shippingAddress' => ['dataSet' => 'US_address_1']]; $productsData = ['products' => $products]; $shippingMethodData = ['shipping' => $shipping]; $paymentData = ['payment' => $payment]; $products = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', $productsData)->run(); $objectManager->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', $products)->run(); $objectManager->create('Magento\\Checkout\\Test\\TestStep\\ProceedToCheckoutStep')->run(); $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingAddressStep', $shippingAddressData)->run(); $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingMethodStep', $shippingMethodData)->run(); $objectManager->create('Magento\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', $paymentData)->run(); $paymentBlock->getSelectedPaymentMethodBlock()->clickPlaceOrder(); \PHPUnit_Framework_Assert::assertEquals(self::NOTIFICATION_MESSAGE, $checkoutOnepage->getAgreementReview()->getNotificationMassage(), 'Notification required message of Terms and Conditions is absent.'); $checkoutOnepage->getAgreementReview()->setAgreement('Yes', $agreement); $paymentBlock->getSelectedPaymentMethodBlock()->clickPlaceOrder(); $assertOrderSuccessPlacedMessage->processAssert($checkoutOnepageSuccess); }
/** * Assert that "Same as Shipping" checkbox of Billing Address selection block is in correct state. * * @param CheckoutOnepage $checkoutOnepage * @param string $billingCheckboxState * @return void */ public function processAssert(CheckoutOnepage $checkoutOnepage, $billingCheckboxState) { $actualResult = $checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->getBillingBlock()->getSameAsShippingCheckboxValue(); \PHPUnit_Framework_Assert::assertEquals($billingCheckboxState, $actualResult, '"Same as Shipping" checkbox has wrong value'); }
/** * Click Continue to PayPal button. * * @return array */ public function run() { $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->inContextPaypalCheckout(); }
/** * Run step that saves credit card. * * @return void */ public function run() { $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->saveCreditCard($this->payment['method'], $this->creditCardSave); }
/** * Click Continue to PayPal button. * * @return array */ public function run() { $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); }
/** * Run step that selects saved credit card. * * @return void */ public function run() { $this->payment['method'] .= '_item_'; $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment); }
/** * Run step that selecting payment method * * @return void */ public function run() { if ($this->payment['method'] !== 'free') { $this->checkoutOnepage->getPaymentBlock()->selectPaymentMethod($this->payment, $this->creditCard); } }