コード例 #1
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();
 }
コード例 #2
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);
     }
 }
コード例 #3
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];
 }
コード例 #4
0
 /**
  * 1. Creating product simple with custom tax product class
  * 2. Log In as customer
  * 3. Add product to shopping cart
  * 4. Estimate Shipping and Tax
  * 5. Implementation assert
  *
  * @param FixtureFactory $fixtureFactory
  * @param TaxRule $taxRule
  * @param Customer $customer
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param Address $address
  * @param array $shipping
  * @param BrowserInterface $browser
  * @param TaxRule $initialTaxRule
  * @return void
  */
 public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, Customer $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, Address $address, array $shipping, BrowserInterface $browser, TaxRule $initialTaxRule = null)
 {
     $this->initialTaxRule = $initialTaxRule;
     $this->taxRule = $taxRule;
     $this->checkoutCart = $checkoutCart;
     $this->shipping = $shipping;
     if ($this->initialTaxRule !== null) {
         $this->taxRuleCode = $this->taxRule->hasData('code') ? $this->taxRule->getCode() : $this->initialTaxRule->getCode();
     } else {
         $this->taxRuleCode = $this->taxRule->getCode();
     }
     // Creating simple product with custom tax class
     /** @var \Magento\Tax\Test\Fixture\TaxClass $taxProductClass */
     $taxProductClass = $taxRule->getDataFieldConfig('tax_product_class')['source']->getFixture()[0];
     $this->productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_100_dollar_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]);
     $this->productSimple->persist();
     // Customer login
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     // Clearing shopping cart and adding product to shopping cart
     $checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $browser->open($_ENV['app_frontend_url'] . $this->productSimple->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCart();
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     // Estimate Shipping and Tax
     $checkoutCart->open();
     $checkoutCart->getShippingBlock()->openEstimateShippingAndTax();
     $checkoutCart->getShippingBlock()->fill($address);
     $checkoutCart->getShippingBlock()->clickGetQuote();
     $checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
     $this->assert();
 }
コード例 #5
0
 /**
  * 1. Creating product simple with custom tax product class
  * 2. Log In as customer
  * 3. Add product to shopping cart
  * 4. Estimate Shipping and Tax
  * 5. Implementation assert
  *
  * @param FixtureFactory $fixtureFactory
  * @param TaxRule $taxRule
  * @param CustomerAccountLogin $customerAccountLogin
  * @param CustomerAccountLogout $customerAccountLogout
  * @param CustomerInjectable $customer
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param AddressInjectable $address
  * @param array $shipping
  * @param TaxRule $initialTaxRule
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(FixtureFactory $fixtureFactory, TaxRule $taxRule, CustomerAccountLogin $customerAccountLogin, CustomerAccountLogout $customerAccountLogout, CustomerInjectable $customer, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, AddressInjectable $address, array $shipping, TaxRule $initialTaxRule = null)
 {
     $this->initialTaxRule = $initialTaxRule;
     $this->taxRule = $taxRule;
     $this->checkoutCart = $checkoutCart;
     $this->shipping = $shipping;
     if ($this->initialTaxRule !== null) {
         $this->taxRuleCode = $this->taxRule->hasData('code') ? $this->taxRule->getCode() : $this->initialTaxRule->getCode();
     } else {
         $this->taxRuleCode = $this->taxRule->getCode();
     }
     // Creating simple product with custom tax class
     /** @var \Magento\Tax\Test\Fixture\TaxClass $taxProductClass */
     $taxProductClass = $taxRule->getDataFieldConfig('tax_product_class')['source']->getFixture()[0];
     $this->productSimple = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => '100_dollar_product_for_tax_rule', 'data' => ['tax_class_id' => ['tax_product_class' => $taxProductClass]]]);
     $this->productSimple->persist();
     // Customer login
     $customerAccountLogout->open();
     $customerAccountLogin->open();
     $customerAccountLogin->getLoginBlock()->login($customer);
     // Clearing shopping cart and adding product to shopping cart
     $checkoutCart->open()->getCartBlock()->clearShoppingCart();
     $catalogProductView->init($this->productSimple);
     $catalogProductView->open();
     $catalogProductView->getViewBlock()->clickAddToCart();
     // Estimate Shipping and Tax
     $checkoutCart->getShippingBlock()->openEstimateShippingAndTax();
     $checkoutCart->getShippingBlock()->fill($address);
     $checkoutCart->getShippingBlock()->clickGetQuote();
     $checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
     $this->assert();
 }
コード例 #6
0
 /**
  * Fill estimate block.
  *
  * @param Address $address
  * @param array $shipping
  * @return void
  */
 public function fillEstimateBlock(Address $address, $shipping)
 {
     $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address);
     $this->checkoutCart->getShippingBlock()->selectShippingMethod($shipping);
 }