/** * Apply coupon before one page checkout. * * @return void */ public function run() { if ($this->salesRule !== null) { $this->checkoutCart->getDiscountCodesBlock()->applyCouponCode($this->salesRule->getCouponCode()); $this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals(); } }
/** * Checkout with Braintree PayPal from Shopping Cart. * * @return void */ public function run() { $this->checkoutCart->open(); $this->checkoutCart->getTotalsBlock()->waitForShippingPriceBlock(); $this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals(); $currentWindow = $this->checkoutCart->getCartBlock()->braintreePaypalCheckout(); $this->checkoutCart->getBraintreePaypalBlock()->process($currentWindow); }
/** * Assert that grand total is equal to expected * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param boolean $requireReload * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireReload = true) { if ($requireReload) { $checkoutCart->open(); $checkoutCart->getTotalsBlock()->waitForUpdatedTotals(); } $fixtureGrandTotal = number_format($cart->getGrandTotal(), 2); $pageGrandTotal = $checkoutCart->getTotalsBlock()->getGrandTotal(); \PHPUnit_Framework_Assert::assertEquals($fixtureGrandTotal, $pageGrandTotal, 'Grand total price in the shopping cart not equals to grand total price from fixture.'); }
/** * Assert that shipping amount is equal to expected. * * @param CheckoutCart $checkoutCart * @param Cart $cart * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart) { $checkoutCart->open(); $fixtureShippingAmount = number_format((double) $cart->getShippingAmount(), 2); $pageShippingAmount = $checkoutCart->getTotalsBlock()->getShippingPrice(); \PHPUnit_Framework_Assert::assertEquals($fixtureShippingAmount, $pageShippingAmount, 'Shipping amount in the shopping cart not equals to shipping amount from fixture.'); }
/** * Get cart prices * * @param CatalogProductSimple $product * @param array $actualPrices * @return array */ protected function getCartPrice(CatalogProductSimple $product, $actualPrices) { $this->checkoutCart->open(); $actualPrices['cart_item_price_incl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getPriceInclTax(); $actualPrices['cart_item_subtotal_incl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPriceInclTax(); $actualPrices['grand_total'] = $this->checkoutCart->getTotalsBlock()->getGrandTotalIncludingTax(); return $actualPrices; }
/** * Assert that Catalog Price Rule is applied for product(s) in Shopping Cart * according to Priority(Priority/Stop Further Rules Processing). * * @param CheckoutCart $checkoutCartPage * @param array $products * @param array $cartPrice * @param array $productPrice * @param Customer $customer * @return void */ public function processAssert(CheckoutCart $checkoutCartPage, array $products, array $cartPrice, array $productPrice, Customer $customer = null) { if ($customer !== null) { $this->objectManager->create('\\Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run(); } $this->objectManager->create('\\Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', ['products' => $products])->run(); $checkoutCartPage->open(); foreach ($products as $key => $product) { $actualPrice = $checkoutCartPage->getCartBlock()->getCartItem($product)->getSubtotalPrice(); \PHPUnit_Framework_Assert::assertEquals($productPrice[$key]['sub_total'], $actualPrice, 'Wrong product price is displayed.' . "\nExpected: " . $productPrice[$key]['sub_total'] . "\nActual: " . $actualPrice . "\n"); } $actualPrices['sub_total'] = $checkoutCartPage->getTotalsBlock()->getSubtotal(); $actualPrices['grand_total'] = $checkoutCartPage->getTotalsBlock()->getGrandTotal(); $expectedPrices['sub_total'] = $cartPrice['sub_total']; $expectedPrices['grand_total'] = $cartPrice['grand_total']; \PHPUnit_Framework_Assert::assertEquals($expectedPrices, $actualPrices, 'Wrong total cart prices are displayed.'); }
/** * Assert that tax amount is equal to expected. * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param boolean $requireReload * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireReload = true) { if ($requireReload) { $checkoutCart->open(); } $fixtureTaxAmount = number_format((double) $cart->getTaxAmount(), 2); $pageTaxAmount = $checkoutCart->getTotalsBlock()->getTax(); \PHPUnit_Framework_Assert::assertEquals($fixtureTaxAmount, $pageTaxAmount, 'Tax amount in the shopping cart not equals to tax amount from fixture.'); }
/** * Estimate shipping and tax and process assertions for totals. * * @return void */ public function run() { $this->checkoutCart->open(); $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); /** @var \Magento\Checkout\Test\Fixture\Cart $cart */ if ($this->cart !== null) { $cart = $this->fixtureFactory->createByCode('cart', ['data' => array_merge($this->cart->getData(), ['items' => ['products' => $this->products]])]); $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($this->address); if (!empty($this->shipping)) { $this->checkoutCart->getShippingBlock()->selectShippingMethod($this->shipping); } $this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals(); $this->assertEstimateShippingAndTax->processAssert($this->checkoutCart, $cart, false); } }
/** * Get cart prices * * @param CatalogProductSimple $product * @param array $actualPrices * @return array */ protected function getCartPrice(CatalogProductSimple $product, array $actualPrices) { $this->checkoutCart->open(); $productItem = $this->checkoutCart->getCartBlock()->getCartItem($product); $productWeeeItem = $this->checkoutCart->getWeeeCartBlock()->getCartItem($product); $actualPrices['cart_item_price'] = $productItem->getPrice(); $actualPrices['cart_item_fpt'] = $productWeeeItem->getPriceFptBlock()->getFpt(); $actualPrices['cart_item_fpt_total'] = $productWeeeItem->getPriceFptBlock()->getFptTotal(); $actualPrices['cart_item_subtotal'] = $productItem->getSubtotalPrice(); $actualPrices['cart_item_subtotal_fpt'] = $productWeeeItem->getSubtotalFptBlock()->getFpt(); $actualPrices['cart_item_subtotal_fpt_total'] = $productWeeeItem->getSubtotalFptBlock()->getFptTotal(); $actualPrices['grand_total'] = $this->checkoutCart->getTotalsBlock()->getGrandTotal(); $actualPrices['total_fpt'] = $this->checkoutCart->getWeeeTotalsBlock()->getFptBlock()->getTotalFpt(); return $actualPrices; }
/** * Assert that discount is equal to expected. * * @param CheckoutCart $checkoutCart * @param Cart $cart * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart) { $checkoutCart->open(); $checkoutCart->getTotalsBlock()->waitForUpdatedTotals(); \PHPUnit_Framework_Assert::assertEquals(number_format($cart->getDiscount(), 2), $checkoutCart->getTotalsBlock()->getDiscount(), 'Discount amount in the shopping cart not equals to discount amount from fixture.'); }