コード例 #1
0
 /**
  * Add gift message to items and/or order.
  *
  * @return array
  */
 public function run()
 {
     $this->checkoutCart->open();
     $this->checkoutCart->getGiftMessagesItemBlock()->fillGiftMessageItem($this->giftMessage, $this->products);
     $this->checkoutCart->getGiftMessagesOrderBlock()->fillGiftMessageOrder($this->giftMessage, $this->products);
     return ['giftMessage' => $this->giftMessage];
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 /**
  * Add products to the cart
  *
  * @return void
  */
 public function run()
 {
     // Ensure that shopping cart is empty
     $this->checkoutCart->open()->getCartBlock()->clearShoppingCart();
     foreach ($this->products as $product) {
         $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
         $this->catalogProductView->getViewBlock()->addToCart($product);
         $this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
     }
 }
 /**
  * Run test add products to shopping cart
  *
  * @param string $products
  * @param int $deletedProductIndex
  * @return array
  */
 public function test($products, $deletedProductIndex)
 {
     // Preconditions
     $products = $this->prepareProducts($products);
     $this->cartPage->open();
     $this->cartPage->getCartBlock()->clearShoppingCart();
     // Steps
     $this->addToCart($products);
     $this->cartPage->getMessagesBlock()->waitSuccessMessage();
     $this->removeProduct($products[$deletedProductIndex]);
     $deletedProduct = $products[$deletedProductIndex];
     unset($products[$deletedProductIndex]);
     return ['products' => $products, 'deletedProduct' => $deletedProduct];
 }
コード例 #5
0
 /**
  * Assert that product is not displayed in cross-sell section.
  *
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param InjectableFixture[]|null $promotedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, array $promotedProducts = null)
 {
     if (!$promotedProducts) {
         $promotedProducts = $product->hasData('cross_sell_products') ? $product->getDataFieldConfig('cross_sell_products')['source']->getProducts() : [];
     }
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     foreach ($promotedProducts as $promotedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->getProductItem($promotedProduct)->isVisible(), 'Product \'' . $promotedProduct->getName() . '\' is exist in cross-sell section.');
     }
 }
コード例 #6
0
 /**
  * Remove products form cart
  *
  * @param array $products
  * @return void
  */
 protected function removeProducts(array $products)
 {
     $this->cartPage->open();
     foreach ($products as $product) {
         $this->cartPage->getCartBlock()->getCartItem($product)->removeItem();
     }
 }
 /**
  * Assert that specified prices are actual on category, product and cart pages.
  *
  * @param InjectableFixture $product
  * @param array $prices
  * @param int $qty
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(InjectableFixture $product, array $prices, $qty, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, FixtureFactory $fixtureFactory)
 {
     $this->cmsIndex = $cmsIndex;
     $this->catalogCategoryView = $catalogCategoryView;
     $this->catalogProductView = $catalogProductView;
     $this->checkoutCart = $checkoutCart;
     //Preconditions
     $address = $fixtureFactory->createByCode('address', ['dataset' => 'US_address_NY']);
     $shipping = ['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed'];
     $actualPrices = [];
     //Assertion steps
     $productCategory = $product->getCategoryIds()[0];
     $this->openCategory($productCategory);
     $actualPrices = $this->getCategoryPrices($product, $actualPrices);
     $catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
     $catalogProductView->getViewBlock()->fillOptions($product);
     $actualPrices = $this->getProductPagePrices($actualPrices);
     $catalogProductView->getViewBlock()->setQtyAndClickAddToCart($qty);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $this->checkoutCart->open();
     $this->fillEstimateBlock($address, $shipping);
     $actualPrices = $this->getCartPrices($product, $actualPrices);
     $actualPrices = $this->getTotals($actualPrices);
     //Prices verification
     $message = 'Prices from dataset should be equal to prices on frontend.';
     \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
 }
コード例 #8
0
 /**
  * Verify checkout cart.
  *
  * @param array $checkoutProducts
  * @return void
  */
 protected function assertCheckoutCart(array $checkoutProducts)
 {
     $this->checkoutCart->open();
     foreach ($checkoutProducts as $product) {
         \PHPUnit_Framework_Assert::assertTrue($this->checkoutCart->getCartBlock()->getCartItem($product)->isVisible(), "Product {$product->getName()} absent in cart.");
     }
 }
コード例 #9
0
 /**
  * 1. Navigate to frontend
  * 2. If "Log Out" link is visible and "isLoggedIn" empty
  *    - makes logout
  * 3. If "isLoggedIn" not empty
  *    - login as customer
  * 4. Clear shopping cart
  * 5. Add test product(s) to shopping cart with specify quantity
  * 6. If "salesRule/data/coupon_code" not empty:
  *    - fill "Enter your code" input in Dіscount Codes
  *    - click "Apply Coupon" button
  * 7. If "address/data/country_id" not empty:
  *    On Estimate Shipping and Tax:
  *    - fill Country, State/Province, Zip/Postal Code
  *    - click 'Get a Quote' button
  *    - select 'Flat Rate' shipping
  *    - click 'Update Total' button
  * 8. Implementation assert
  *
  * @param CheckoutCart $checkoutCart
  * @param CmsIndex $cmsIndex
  * @param CustomerAccountLogin $customerAccountLogin
  * @param CustomerAccountLogout $customerAccountLogout
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @param SalesRule $salesRule
  * @param SalesRule $salesRuleOrigin
  * @param array $productQuantity
  * @param CatalogProductSimple $productForSalesRule1
  * @param CatalogProductSimple $productForSalesRule2
  * @param Customer $customer
  * @param Address $address
  * @param int|null $isLoggedIn
  * @param array $shipping
  * @param array $cartPrice
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(CheckoutCart $checkoutCart, CmsIndex $cmsIndex, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, SalesRule $salesRule, SalesRule $salesRuleOrigin, array $productQuantity, CatalogProductSimple $productForSalesRule1, CatalogProductSimple $productForSalesRule2 = null, Customer $customer = null, Address $address = null, $isLoggedIn = null, array $shipping = [], array $cartPrice = [])
 {
     $this->checkoutCart = $checkoutCart;
     $this->cmsIndex = $cmsIndex;
     $this->customerAccountLogin = $customerAccountLogin;
     $this->customerAccountLogout = $customerAccountLogout;
     $this->catalogCategoryView = $catalogCategoryView;
     $this->catalogProductView = $catalogProductView;
     $this->productForSalesRule1 = $productForSalesRule1;
     $this->productForSalesRule2 = $productForSalesRule2;
     $this->cartPrice = $cartPrice;
     if ($customer !== null) {
         $this->customer = $customer;
     }
     $isLoggedIn ? $this->login() : $this->customerAccountLogout->open();
     $this->checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $this->addProductsToCart($productQuantity);
     $this->checkoutCart->open();
     if ($address !== null) {
         $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address);
         $this->checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
     }
     if ($salesRule->getCouponCode() || $salesRuleOrigin->getCouponCode()) {
         $this->checkoutCart->getDiscountCodesBlock()->applyCouponCode($salesRule->getCouponCode() ? $salesRule->getCouponCode() : $salesRuleOrigin->getCouponCode());
     }
     $this->assert();
 }
コード例 #10
0
 /**
  * Assert prices on the product view page and shopping cart page.
  *
  * @param BundleProduct $product
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCartView
  * @param BundleProduct $originalProduct [optional]
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function assertPrice(BundleProduct $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCartView, BundleProduct $originalProduct = null)
 {
     $customerGroup = 'NOT LOGGED IN';
     $bundleData = $product->getData();
     $this->productPriceType = $originalProduct !== null ? $originalProduct->getPriceType() : $product->getPriceType();
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCartView->open();
     $cartItem = $checkoutCartView->getCartBlock()->getCartItem($product);
     $specialPrice = 0;
     if (isset($bundleData['group_price'])) {
         $specialPrice = $bundleData['group_price'][array_search($customerGroup, $bundleData['group_price'])]['price'] / 100;
     }
     $optionPrice = [];
     $fillData = $product->getCheckoutData();
     foreach ($fillData['options']['bundle_options'] as $key => $data) {
         $subProductPrice = 0;
         foreach ($bundleData['bundle_selections']['products'][$key] as $productKey => $itemProduct) {
             if (strpos($itemProduct->getName(), $data['value']['name']) !== false) {
                 $data['value']['key'] = $productKey;
                 $subProductPrice = $itemProduct->getPrice();
             }
         }
         $optionPrice[$key]['price'] = $this->productPriceType == 'Fixed' ? number_format($bundleData['bundle_selections']['bundle_options'][$key]['assigned_products'][$data['value']['key']]['data']['selection_price_value'], 2) : number_format($subProductPrice, 2);
     }
     foreach ($optionPrice as $index => $item) {
         $item['price'] -= $item['price'] * $specialPrice;
         \PHPUnit_Framework_Assert::assertEquals(number_format($item['price'], 2), $cartItem->getPriceBundleOptions($index + 1), 'Bundle item ' . ($index + 1) . ' options on frontend don\'t equal to fixture.');
     }
     $sumOptionsPrice = $product->getDataFieldConfig('price')['source']->getPriceData()['cart_price'];
     $subTotal = number_format($cartItem->getPrice(), 2);
     \PHPUnit_Framework_Assert::assertEquals($sumOptionsPrice, $subTotal, 'Bundle unit price on frontend doesn\'t equal to fixture.');
 }
コード例 #11
0
 /**
  * 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.');
 }
コード例 #12
0
 /**
  * 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.');
 }
コード例 #13
0
 /**
  * Assert prices on the shopping cart
  *
  * @param FixtureInterface $product
  * @param CheckoutCart $checkoutCart
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
 {
     $checkoutCart->open();
     /** @var CatalogProductSimple $product */
     $customOptions = $product->getCustomOptions();
     $checkoutData = $product->getCheckoutData();
     $checkoutCartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
     $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
     $fixturePrice = $product->getPrice();
     $specialPrice = $product->getSpecialPrice();
     $cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
     $formPrice = $cartItem->getPrice();
     if ($specialPrice) {
         $fixturePrice = $specialPrice;
     }
     if (isset($checkoutCartItem['price'])) {
         $fixturePrice = $checkoutCartItem['price'];
     }
     $fixtureActualPrice = $fixturePrice;
     foreach ($checkoutCustomOptions as $checkoutOption) {
         $attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']);
         $optionKey = str_replace('option_key_', '', $checkoutOption['value']);
         $option = $customOptions[$attributeKey]['options'][$optionKey];
         if ('Fixed' == $option['price_type']) {
             $fixtureActualPrice += $option['price'];
         } else {
             $fixtureActualPrice += $fixturePrice / 100 * $option['price'];
         }
     }
     \PHPUnit_Framework_Assert::assertEquals($fixtureActualPrice, $formPrice, 'Product price in shopping cart is not correct.');
 }
 /**
  * Assert that products are present in shopping cart
  *
  * @param CheckoutCart $checkoutCart
  * @param array $products
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, array $products)
 {
     $checkoutCart->open();
     foreach ($products as $product) {
         \PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCartBlock()->getCartItem($product)->isVisible(), 'Product ' . $product->getName() . ' is absent in shopping cart.');
     }
 }
コード例 #15
0
 /**
  * Check that Shopping Cart is empty, opened page contains text "You have no items in your shopping cart.
  * Click here to continue shopping." where 'here' is link that leads to index page
  *
  * @param CheckoutCart $checkoutCart
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCart, BrowserInterface $browser)
 {
     $checkoutCart->open();
     $cartEmptyBlock = $checkoutCart->getCartEmptyBlock();
     \PHPUnit_Framework_Assert::assertEquals(self::TEXT_EMPTY_CART, $cartEmptyBlock->getText(), 'Wrong text on empty cart page.');
     $cartEmptyBlock->clickLinkToMainPage();
     \PHPUnit_Framework_Assert::assertEquals($_ENV['app_frontend_url'], $browser->getUrl(), 'Wrong link to main page on empty cart page.');
 }
コード例 #16
0
 /**
  * Assert that displayed price for bundle items on shopping cart page equals to passed from fixture.
  *   Price for bundle items has two options:
  *   1. Fixed (price of bundle product)
  *   2. Dynamic (price of bundle item)
  *
  * @param CatalogProductView $catalogProductView
  * @param CatalogProductBundle $product
  * @param CheckoutCart $checkoutCartView
  * @param Browser $browser
  * @param CatalogProductBundle $originalProduct [optional]
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, CatalogProductBundle $product, CheckoutCart $checkoutCartView, Browser $browser, CatalogProductBundle $originalProduct = null)
 {
     $checkoutCartView->open()->getCartBlock()->clearShoppingCart();
     //Open product view page
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     //Process assertions
     $this->assertPrice($product, $catalogProductView, $checkoutCartView, $originalProduct);
 }
コード例 #17
0
 /**
  * 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 Catalog Price Rule is not applied for product(s) in Shopping Cart.
  *
  * @param CheckoutCart $checkoutCartPage
  * @param array $products
  * @param array $productPrice
  * @return void
  */
 public function processAssert(CheckoutCart $checkoutCartPage, array $products, array $productPrice)
 {
     $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]['regular'], $actualPrice, 'Wrong product price is displayed.' . "\nExpected: " . $productPrice[$key]['regular'] . "\nActual: " . $actualPrice . "\n");
     }
 }
コード例 #19
0
 /**
  * Get cart prices.
  *
  * @param InjectableFixture $product
  * @param $actualPrices
  * @return array
  */
 public function getCartPrices(InjectableFixture $product, $actualPrices)
 {
     $this->checkoutCart->open();
     $actualPrices['cart_item_price_excl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getPriceExclTax();
     $actualPrices['cart_item_price_incl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getPriceInclTax();
     $actualPrices['cart_item_subtotal_excl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPriceExclTax();
     $actualPrices['cart_item_subtotal_incl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPriceInclTax();
     return $actualPrices;
 }
コード例 #20
0
 /**
  * Assertion that the product is correctly displayed in cart
  *
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param ConfigurableProduct $product
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, ConfigurableProduct $product)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutData = $product->getCheckoutData();
     $price = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
     \PHPUnit_Framework_Assert::assertEquals($checkoutData['cartItem']['price'], $price, 'Product price in shopping cart is not correct.');
 }
コード例 #21
0
 /**
  * Assert that product is displayed in cross-sell section
  *
  * @param CatalogProductSimple $product1
  * @param CatalogProductSimple $product2
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(CatalogProductSimple $product1, CatalogProductSimple $product2, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart)
 {
     $categoryName = $product1->getCategoryIds()[0];
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product1->getName());
     $catalogProductView->getViewBlock()->addToCart($product1);
     \PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCrosssellBlock()->verifyProductCrosssell($product2), 'Product \'' . $product2->getName() . '\' is absent in cross-sell section.');
 }
コード例 #22
0
 /**
  * Assert that product is not displayed in cross-sell section
  *
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param InjectableFixture[] $relatedProducts
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, array $relatedProducts, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart)
 {
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     foreach ($relatedProducts as $relatedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($checkoutCart->getCrosssellBlock()->verifyProductCrosssell($relatedProduct), 'Product \'' . $relatedProduct->getName() . '\' is exist in cross-sell section.');
     }
 }
コード例 #23
0
 /**
  * Automatic Apply Tax Based on VAT ID.
  *
  * @param ConfigData $vatConfig
  * @param OrderInjectable $order
  * @param TaxRule $taxRule
  * @param Cart $cart
  * @param string $configData
  * @param string $customerGroup
  * @return array
  */
 public function test(ConfigData $vatConfig, OrderInjectable $order, TaxRule $taxRule, Cart $cart, $configData, $customerGroup)
 {
     // Preconditions
     $this->configData = $configData;
     $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run();
     $taxRule->persist();
     // Prepare data
     $this->customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer();
     $address = $this->customer->getDataFieldConfig('address')['source']->getAddresses()[0];
     $this->prepareVatConfig($vatConfig, $customerGroup);
     $poducts = $order->getEntityId()['products'];
     $cart = $this->fixtureFactory->createByCode('cart', ['data' => array_merge($cart->getData(), ['items' => ['products' => $poducts]])]);
     // Steps
     $order->persist();
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $this->customer])->run();
     $this->objectManager->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', $order->getEntityId())->run();
     $this->checkoutCart->open();
     $this->checkoutCart->getCartBlock()->waitCartContainerLoading();
     $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address);
     $this->checkoutCart->getCartBlock()->waitCartContainerLoading();
     return ['customer' => $this->customer, 'address' => $address, 'orderId' => $order->getId(), 'cart' => $cart, 'products' => $poducts];
 }
コード例 #24
0
 /**
  * Assert that product is displayed in cross-sell section
  *
  * @param BrowserInterface $browser
  * @param CheckoutCart $checkoutCart
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param InjectableFixture[] $relatedProducts
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CheckoutCart $checkoutCart, CatalogProductSimple $product, CatalogProductView $catalogProductView, array $relatedProducts)
 {
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->addToCart($product);
     $errors = [];
     foreach ($relatedProducts as $relatedProduct) {
         if (!$checkoutCart->getCrosssellBlock()->verifyProductCrosssell($relatedProduct)) {
             $errors[] = 'Product \'' . $relatedProduct->getName() . '\' is absent in cross-sell section.';
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, implode(" ", $errors));
 }
コード例 #25
0
 /**
  * Assert that cross-sell products section is displayed correctly.
  *
  * @param array $promotedProductNames
  * @return void
  */
 protected function assertCrossSellSection(array $promotedProductNames)
 {
     $productNames = [];
     $pageProductNames = [];
     foreach ($promotedProductNames as $promotedProductName) {
         $productNames[] = $this->products[$promotedProductName]->getName();
     }
     $this->checkoutCart->open();
     foreach ($this->checkoutCart->getCrosssellBlock()->getProducts() as $productItem) {
         $pageProductNames[] = $productItem->getProductName();
     }
     sort($productNames);
     sort($pageProductNames);
     \PHPUnit_Framework_Assert::assertEquals($productNames, $pageProductNames, 'Wrong products are displayed in cross-sell section.');
 }
コード例 #26
0
 /**
  * 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;
 }
コード例 #27
0
 /**
  * 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 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.');
 }
コード例 #29
0
 /**
  * Assert product MAP related data in Shopping Cart.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, InjectableFixture $product)
 {
     /** @var CatalogProductSimple $product */
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
     $catalogCategoryView->getListProductBlock()->getProductItem($product)->open();
     if ($product->hasData('checkout_data')) {
         $catalogProductView->getViewBlock()->addToCart($product);
     } else {
         $catalogProductView->getMsrpViewBlock()->openMapBlock();
         $catalogProductView->getMsrpViewBlock()->getMapBlock()->addToCart();
     }
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $productPrice = $product->hasData('checkout_data') ? $product->getCheckoutData()['cartItem']['price'] : $product->getPrice();
     $unitPrice = $checkoutCart->getCartBlock()->getCartItem($product)->getPrice();
     \PHPUnit_Framework_Assert::assertEquals($productPrice, $unitPrice, 'Incorrect unit price is displayed in Cart');
 }
コード例 #30
0
 /**
  * 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.');
 }