/** * Place order after checking order totals on review step. * * @return array */ public function run() { if (!empty($this->prices)) { $this->assertOrderTotalOnReviewPage->processAssert($this->checkoutOnepage, $this->prices); } $this->checkoutOnepage->getReviewBlock()->placeOrder(); 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->getReviewBlock()->placeOrder(); return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()]; }
/** * Assert that Catalog Price Rule is applied & it impacts on product's discount price on OnePage Checkout page. * * @param CheckoutOnepage $checkoutOnepage * @param Customer $customer * @param array $products * @param array $cartPrice * @param array $shipping * @param array $payment * @return void */ public function processAssert(CheckoutOnepage $checkoutOnepage, Customer $customer, array $products, array $cartPrice, array $shipping, array $payment) { $this->objectManager->create('\\Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); $this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', ['products' => $products])->run(); $this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\ProceedToCheckoutStep')->run(); $this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\FillBillingInformationStep', ['customer' => $customer, 'checkoutMethod' => 'register'])->run(); $this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\FillShippingMethodStep', ['shipping' => $shipping])->run(); $this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', ['payment' => $payment])->run(); $actualPrices['grand_total'] = $checkoutOnepage->getReviewBlock()->getGrandTotal(); $actualPrices['sub_total'] = $checkoutOnepage->getReviewBlock()->getSubtotal(); $expectedPrices['grand_total'] = $cartPrice['grand_total'] + $cartPrice['shipping_price']; $expectedPrices['sub_total'] = $cartPrice['sub_total']; \PHPUnit_Framework_Assert::assertEquals($expectedPrices, $actualPrices, 'Wrong total cart prices are displayed.'); }
/** * 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) { $this->checkoutOnepage = $checkoutOnepage; $this->customerOrderView = $customerOrderView; $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout(); $checkoutOnepage->getBillingBlock()->clickContinue(); $checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod(['method' => 'check_money_order']); $checkoutOnepage->getPaymentMethodsBlock()->clickContinue(); $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, $actualPrices, $message); $checkoutOnepage->getReviewBlock()->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); }
/** * Get review product prices. * * @param InjectableFixture $product * @param $actualPrices * @return array */ public function getReviewPrices($actualPrices, InjectableFixture $product) { $reviewBlock = $this->checkoutOnepage->getReviewBlock(); $actualPrices['cart_item_price_excl_tax'] = $reviewBlock->getItemPriceExclTax($product->getName()); $actualPrices['cart_item_price_incl_tax'] = $reviewBlock->getItemPriceInclTax($product->getName()); $actualPrices['cart_item_subtotal_excl_tax'] = $reviewBlock->getItemSubExclTax($product->getName()); $actualPrices['cart_item_subtotal_incl_tax'] = $reviewBlock->getItemSubInclTax($product->getName()); return $actualPrices; }
/** * Assert that Order Grand Total is correct on checkoutOnePage * * @param CheckoutOnepage $checkoutOnepage * @param string $grandTotal * @return void */ public function processAssert(CheckoutOnepage $checkoutOnepage, $grandTotal) { $checkoutReviewGrandTotal = $checkoutOnepage->getReviewBlock()->getGrandTotal(); \PHPUnit_Framework_Assert::assertEquals($checkoutReviewGrandTotal, number_format($grandTotal, 2), "Grand Total price: {$checkoutReviewGrandTotal} not equals with price from data set: " . $grandTotal); }
/** * Assert that Order Subtotal is correct on Review page. * * @param CheckoutOnepage $checkoutOnepage * @param string $subTotal * @return void */ public function processAssert(CheckoutOnepage $checkoutOnepage, $subTotal) { $reviewSubTotal = $checkoutOnepage->getReviewBlock()->getSubtotal(); \PHPUnit_Framework_Assert::assertEquals($reviewSubTotal, number_format($subTotal, 2), 'Subtotal price: \'' . $reviewSubTotal . '\' not equals with price from data set: \'' . $reviewSubTotal . '\''); }
/** * Assert that Order Grand Total is correct on checkoutOnePage * * @param CheckoutOnepage $checkoutOnepage * @param string $grandTotal * @return void */ public function processAssert(CheckoutOnepage $checkoutOnepage, $grandTotal) { $checkoutReviewGrandTotal = $checkoutOnepage->getReviewBlock()->getGrandTotal(); \PHPUnit_Framework_Assert::assertEquals($checkoutReviewGrandTotal, $grandTotal, 'Grand Total price: \'' . $checkoutReviewGrandTotal . '\' not equals with price from data set: \'' . $grandTotal . '\''); }
/** * Assert that total tax price is correct on Review page. * * @param CheckoutOnepage $checkoutOnepage * @param string $taxTotal * @return void */ public function processAssert(CheckoutOnepage $checkoutOnepage, $taxTotal) { $reviewTaxTotal = $checkoutOnepage->getReviewBlock()->getTax(); \PHPUnit_Framework_Assert::assertEquals($reviewTaxTotal, number_format($taxTotal, 2), "Tax price '{$reviewTaxTotal}' not equals with price from data set '{$taxTotal}'."); }