コード例 #1
0
ファイル: Curl.php プロジェクト: andrewhowdencom/m2onk8s
 /**
  * Prepare tax rule field data using new field.
  *
  * @param TaxRule $fixture
  * @param array $data
  * @param string $fixtureField
  * @param string $newField
  * @return array
  */
 public function prepareFieldData(TaxRule $fixture, array $data, $fixtureField, $newField = null)
 {
     $newField = $newField === null ? $fixtureField : $newField;
     unset($data[$fixtureField]);
     if (!$fixture->hasData($fixtureField)) {
         $data[$newField][] = $this->defaultTaxClasses[$fixtureField];
     } else {
         foreach ($fixture->getDataFieldConfig($fixtureField)['source']->getFixture() as $taxField) {
             if (!$taxField->hasData('id')) {
                 $taxField->persist();
             }
             $data[$newField][] = $taxField->getId();
         }
     }
     return $data;
 }
コード例 #2
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();
 }
コード例 #3
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();
 }
コード例 #4
0
ファイル: Form.php プロジェクト: andrewhowdencom/m2onk8s
 /**
  * Method to add new tax rate.
  *
  * @param TaxRule $taxRule
  * @return void
  */
 protected function addNewTaxRates($taxRule)
 {
     $rootForm = $this;
     $taxRateMultiSelectList = $this->taxRateMultiSelectList;
     $taxRateDefaultMultiSelect = $this->taxRateDefaultMultiSelect;
     $this->browser->waitUntil(function () use($rootForm, $taxRateDefaultMultiSelect) {
         $element = $rootForm->browser->find($taxRateDefaultMultiSelect);
         return $element->isVisible() ? null : true;
     });
     $this->browser->waitUntil(function () use($rootForm, $taxRateMultiSelectList) {
         $element = $rootForm->browser->find($taxRateMultiSelectList);
         return $element->isVisible() ? true : null;
     });
     $taxRateBlock = $this->_rootElement->find($this->taxRateBlock, Locator::SELECTOR_CSS, 'multiselectlist');
     /** @var \Magento\Tax\Test\Block\Adminhtml\Rule\Edit\TaxRate $taxRateForm */
     $taxRateForm = $this->blockFactory->create('Magento\\Tax\\Test\\Block\\Adminhtml\\Rule\\Edit\\TaxRate', ['element' => $this->browser->find($this->taxRateForm)]);
     /** @var \Magento\Tax\Test\Fixture\TaxRule\TaxRate $taxRatesFixture */
     $taxRatesFixture = $taxRule->getDataFieldConfig('tax_rate')['source'];
     $taxRatesFixture = $taxRatesFixture->getFixture();
     $taxRatesData = $taxRule->getTaxRate();
     foreach ($taxRatesData as $key => $taxRate) {
         $option = $taxRateBlock->find(sprintf($this->optionMaskElement, $taxRate), Locator::SELECTOR_XPATH);
         if (!$option->isVisible()) {
             $taxRate = $taxRatesFixture[$key];
             $this->clickAddNewButton($taxRateBlock);
             $taxRateForm->fill($taxRate);
             $taxRateForm->saveTaxRate();
             /** @var \Magento\Tax\Test\Fixture\TaxRate $taxRate */
             $code = $taxRate->getCode();
             $this->waitUntilOptionIsVisible($taxRateBlock, $code);
         }
     }
 }
コード例 #5
0
 /**
  * Assert sales info in report: Tax, Rate, Orders, Tax Amount on tax report page
  *
  * @param SalesTaxReport $salesTaxReport
  * @param OrderInjectable $order
  * @param TaxRule $taxRule
  * @param string $taxAmount
  * @return void
  */
 public function processAssert(SalesTaxReport $salesTaxReport, OrderInjectable $order, TaxRule $taxRule, $taxAmount)
 {
     $filter = ['tax' => $taxRule->getTaxRate()[0], 'rate' => $taxRule->getDataFieldConfig('tax_rate')['source']->getFixture()[0]->getRate(), 'orders' => count($order->getEntityId()['products']), 'tax_amount' => $taxAmount];
     \PHPUnit_Framework_Assert::assertTrue($salesTaxReport->getGridBlock()->isRowVisible($filter, false), "Tax Report is not visible in grid on tax report page.");
 }