/** * Assert that grand total is equal to expected. * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param Customer|null $customer * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, Customer $customer = null) { if ($customer !== null) { $this->login($customer); } $checkoutCart->open(); \PHPUnit_Framework_Assert::assertEquals(number_format($cart->getGrandTotal(), 2), $checkoutCart->getTotalsBlock()->getData('grand_total')); }
/** * Prepare options. * * @param Cart $cart * @return array */ protected function prepareOptions(Cart $cart) { $data = []; $options = $cart->getItems()[0]->getData()['options']; foreach ($options as $key => $option) { foreach ($option as $index => $value) { $data[$key][$index] = strtoupper($value); } } return $this->sortDataByPath($data, '::title'); }
/** * 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()->getTopLinksBlock()->openMiniCart(); /** @var Items $sourceProducts */ $products = $cart->getDataFieldConfig('items')['source']->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()->getCartItem($product)->getQty()]; } $error = $this->verifyData($productsData, $miniCartData, true); \PHPUnit_Framework_Assert::assertEmpty($error, $error); }
/** * Assert that $dataType in the shopping cart equals to expected $dataType from data set. * * @param CheckoutCart $checkoutCart * @param Cart $cart * @param array $verifyData [optional] * @return void */ public function processAssert(CheckoutCart $checkoutCart, Cart $cart, array $verifyData = []) { $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]; $data = isset($verifyData[$key]) ? $verifyData[$key] : []; $productName = $product->getName(); /** @var FixtureInterface $item */ $checkoutItem = $item->getData(); $cartItem = $checkoutCart->getCartBlock()->getCartItem($product); $productsData[$productName] = $this->getProductData($checkoutItem, $data); $cartData[$productName] = $this->getCartData($cartItem); } $error = $this->verifyContainsData($productsData, $cartData); \PHPUnit_Framework_Assert::assertEmpty($error, $error); }
/** * 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(); \PHPUnit_Framework_Assert::assertEquals(number_format($cart->getGrandTotal(), 2), $checkoutCart->getTotalsBlock()->getData('grand_total')); }