/** * 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.'); }
/** * Assert that grand total is equal to expected * * @param CheckoutCart $checkoutCart * @param Cart $cart * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart) { $checkoutCart->open(); $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 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.'); }
/** * Assert that grand total is equal to expected. * Assert that subtotal total in the shopping cart is equals to expected total from data set. * Assert that tax amount is equal to expected. * Assert that shipping 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 ($cart->hasData('tax_amount')) { $this->assertTaxInShoppingCart->processAssert($checkoutCart, $cart, $requireReload); } if ($cart->hasData('subtotal')) { $this->assertSubtotalInShoppingCart->processAssert($checkoutCart, $cart, $requireReload); } if ($cart->hasData('grand_total')) { $this->assertGrandTotalInShoppingCart->processAssert($checkoutCart, $cart, $requireReload); } if ($cart->hasData('shipping_amount')) { $this->assertShippingInShoppingCart->processAssert($checkoutCart, $cart, $requireReload); } }
/** * Assert that product quantity in the mini shopping cart is equals to expected quantity from data set * * @param CmsIndex $cmsIndex * @param Cart $cart * @return void */ public function processAssert(CmsIndex $cmsIndex, Cart $cart) { $cmsIndex->open(); /** @var Items $sourceProducts */ $sourceProducts = $cart->getDataFieldConfig('items')['source']; $products = $sourceProducts->getProducts(); $items = $cart->getItems(); $productsData = []; $miniCartData = []; foreach ($items as $key => $item) { /** @var CatalogProductSimple $product */ $product = $products[$key]; $productName = $product->getName(); /** @var FixtureInterface $item */ $checkoutItem = $item->getData(); $productsData[$productName] = ['qty' => $checkoutItem['qty']]; $miniCartData[$productName] = ['qty' => $cmsIndex->getCartSidebarBlock()->getProductQty($productName)]; } $error = $this->verifyData($productsData, $miniCartData, true); \PHPUnit_Framework_Assert::assertEmpty($error, $error); }
/** * Assert that cart item options for product(s) display with correct information block * (custom options, variations, links, samples, bundle items etc) according to passed from dataset. * * @param CheckoutCart $checkoutCart * @param Cart $cart * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart) { $checkoutCart->open(); /** @var Items $sourceProducts */ $sourceProducts = $cart->getDataFieldConfig('items')['source']; $products = $sourceProducts->getProducts(); $items = $cart->getItems(); $productsData = []; $cartData = []; foreach ($items as $key => $item) { /** @var CatalogProductSimple $product */ $product = $products[$key]; $productName = $product->getName(); /** @var FixtureInterface $item */ $checkoutItem = $item->getData(); $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); $productsData[$productName] = ['options' => $this->sortDataByPath($checkoutItem['options'], '::title')]; $cartData[$productName] = ['options' => $this->sortDataByPath($cartItem->getOptions(), '::title')]; } $error = $this->verifyContainsData($productsData, $cartData, true); \PHPUnit_Framework_Assert::assertEmpty($error, $error); }
/** * 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); } }
/** * Assert that subtotal total in the shopping cart is equals to expected total from data set * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param boolean $requireReload * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, $requireReload = true) { if ($requireReload) { $checkoutCart->open(); } /** @var Items $sourceProducts */ $sourceProducts = $cart->getDataFieldConfig('items')['source']; $products = $sourceProducts->getProducts(); $items = $cart->getItems(); $productsData = []; $cartData = []; foreach ($items as $key => $item) { /** @var CatalogProductSimple $product */ $product = $products[$key]; $productName = $product->getName(); /** @var FixtureInterface $item */ $checkoutItem = $item->getData(); $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); $productsData[$productName] = ['subtotal' => $checkoutItem['subtotal']]; $cartData[$productName] = ['subtotal' => $cartItem->getSubtotalPrice()]; } $error = $this->verifyData($productsData, $cartData, true); \PHPUnit_Framework_Assert::assertEmpty($error, $error); }
/** * Assert that product quantity in the mini shopping cart is equals to expected quantity from data set * * @param CmsIndex $cmsIndex * @param Cart $cart * @param CatalogProductSimple $product * @return void */ public function processAssert(CmsIndex $cmsIndex, Cart $cart, CatalogProductSimple $product) { $productQtyInMiniCart = $cmsIndex->open()->getCartSidebarBlock()->getProductQty($product->getName()); \PHPUnit_Framework_Assert::assertEquals($productQtyInMiniCart, $cart->getQty(), 'Mini shopping cart product qty: \'' . $productQtyInMiniCart . '\' not equals with qty from data set: \'' . $cart->getQty() . '\''); }
/** * Assert that price in the shopping cart equals to expected price from data set * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param CatalogProductSimple $product * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductSimple $product) { $checkoutCart->open(); $cartProductPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); \PHPUnit_Framework_Assert::assertEquals($cartProductPrice, $cart->getPrice(), 'Shopping cart product price: \'' . $cartProductPrice . '\' not equals with price from data set: \'' . $cart->getPrice() . '\''); }
/** * 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.'); }
/** * Assert that quantity in the shopping cart is equals to expected quantity from data set * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param CatalogProductSimple $product * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductSimple $product) { $cartProductQty = $checkoutCart->open()->getCartBlock()->getProductQty($product->getName()); \PHPUnit_Framework_Assert::assertEquals($cartProductQty, $cart->getQty(), 'Shopping cart product qty: \'' . $cartProductQty . '\' not equals with qty from data set: \'' . $cart->getQty() . '\''); }
/** * Assert that subtotal total in the shopping cart is equals to expected total from data set * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param CatalogProductSimple $product * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductSimple $product) { $cartProductSubtotal = $checkoutCart->open()->getCartBlock()->getCartItemSubTotalByProductName($product->getName()); \PHPUnit_Framework_Assert::assertEquals($cartProductSubtotal, $cart->getRowTotal(), 'Shopping cart subtotal: \'' . $cartProductSubtotal . '\' not equals with total from data set: \'' . $cart->getRowTotal() . '\''); }