From 3ff27c21c8b2a1b1bebddd8d1b3c382f3f46526f Mon Sep 17 00:00:00 2001 From: Mike Weis Date: Thu, 18 Dec 2014 16:54:21 -0600 Subject: [PATCH 01/18] MAGETWO-31118: Subtotal Including Tax on invoice is discounted - fixed --- .../Model/Order/Invoice/Total/Subtotal.php | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php b/app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php index 959820d77123f..b15fce9617df9 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php @@ -36,46 +36,15 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice) $allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced(); $baseAllowedSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalInvoiced(); - $allowedSubtotalInclTax = $allowedSubtotal + - $order->getHiddenTaxAmount() + - $order->getTaxAmount() - - $order->getTaxInvoiced() - - $order->getHiddenTaxInvoiced(); - $baseAllowedSubtotalInclTax = $baseAllowedSubtotal + - $order->getBaseHiddenTaxAmount() + - $order->getBaseTaxAmount() - - $order->getBaseTaxInvoiced() - - $order->getBaseHiddenTaxInvoiced(); - - /** - * Check if shipping tax calculation is included to current invoice. - */ - $includeShippingTax = true; - foreach ($invoice->getOrder()->getInvoiceCollection() as $previousInvoice) { - if ($previousInvoice->getShippingAmount() && !$previousInvoice->isCanceled()) { - $includeShippingTax = false; - break; - } - } - - if ($includeShippingTax) { - $allowedSubtotalInclTax -= $order->getShippingTaxAmount(); - $baseAllowedSubtotalInclTax -= $order->getBaseShippingTaxAmount(); - } else { - $allowedSubtotalInclTax += $order->getShippingHiddenTaxAmount(); - $baseAllowedSubtotalInclTax += $order->getBaseShippingHiddenTaxAmount(); - } + //Note: The $subtotalInclTax and $baseSubtotalInclTax are not adjusted from those provide by the line items + //because the "InclTax" is displayed before any tax adjustments based on discounts, shipping, etc. if ($invoice->isLast()) { $subtotal = $allowedSubtotal; $baseSubtotal = $baseAllowedSubtotal; - $subtotalInclTax = $allowedSubtotalInclTax; - $baseSubtotalInclTax = $baseAllowedSubtotalInclTax; } else { $subtotal = min($allowedSubtotal, $subtotal); $baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal); - $subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax); - $baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax); } $invoice->setSubtotal($subtotal); From 375d189372b7291d3529f0e0fa5113aaefbe3324 Mon Sep 17 00:00:00 2001 From: Mike Weis Date: Fri, 19 Dec 2014 11:16:06 -0600 Subject: [PATCH 02/18] MAGETWO-28549: typo in public function getCalculationAgorithm - fixed --- .../Bundle/Pricing/Adjustment/Calculator.php | 2 +- app/code/Magento/Tax/Helper/Data.php | 2 +- app/code/Magento/Tax/Model/Config.php | 2 +- app/code/Magento/Tax/Model/Observer.php | 2 +- .../Weee/Model/Total/Quote/WeeeTaxTest.php | 18 ++++++++--------- .../Weee/Model/Total/Quote/WeeeTest.php | 20 +++++++++---------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php b/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php index e15bbbf89f1df..3a1c5b56dc592 100644 --- a/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php +++ b/app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php @@ -313,7 +313,7 @@ protected function calculateDynamicBundleAmount($basePriceValue, $bundleProduct, /** @var Store $store */ $store = $bundleProduct->getStore(); - $roundingMethod = $this->taxHelper->getCalculationAgorithm($store); + $roundingMethod = $this->taxHelper->getCalculationAlgorithm($store); foreach ($amountList as $amountInfo) { /** @var \Magento\Framework\Pricing\Amount\AmountInterface $itemAmount */ $itemAmount = $amountInfo['amount']; diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index 26e3386435f47..9ce9e7ca4d5f0 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -628,7 +628,7 @@ public function getCalculationSequence($store = null) * @param null|string|bool|int|Store $store * @return string */ - public function getCalculationAgorithm($store = null) + public function getCalculationAlgorithm($store = null) { return $this->_config->getAlgorithm($store); } diff --git a/app/code/Magento/Tax/Model/Config.php b/app/code/Magento/Tax/Model/Config.php index bfd8e11e64910..86a5e6d7dbcd6 100644 --- a/app/code/Magento/Tax/Model/Config.php +++ b/app/code/Magento/Tax/Model/Config.php @@ -269,7 +269,7 @@ public function getNeedUseShippingExcludeTax() } /** - * Get defined tax calculation agorithm + * Get defined tax calculation algorithm * * @param null|string|bool|int|Store $store * @return string diff --git a/app/code/Magento/Tax/Model/Observer.php b/app/code/Magento/Tax/Model/Observer.php index da2ad2ba127f5..d674c3d7a4715 100644 --- a/app/code/Magento/Tax/Model/Observer.php +++ b/app/code/Magento/Tax/Model/Observer.php @@ -299,7 +299,7 @@ public function updateProductOptions(\Magento\Framework\Event\Observer $observer return $this; } - $algorithm = $this->_taxData->getCalculationAgorithm(); + $algorithm = $this->_taxData->getCalculationAlgorithm(); $options['calculationAlgorithm'] = $algorithm; // prepare correct template for options render if ($this->_taxData->displayBothPrices()) { diff --git a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php index 6086e0a44b09a..ab317faba4dbe 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTaxTest.php @@ -278,7 +278,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -322,7 +322,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_taxable_unit_not_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -366,7 +366,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -410,7 +410,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_non_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -448,7 +448,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_non_taxable_unit_include_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -486,7 +486,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_taxable_row_include_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -530,7 +530,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_taxable_row_include_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -574,7 +574,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_non_taxable_row_include_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -612,7 +612,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, diff --git a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php index 62935f81d6bf4..fd673096c7ed1 100644 --- a/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php +++ b/dev/tests/unit/testsuite/Magento/Weee/Model/Total/Quote/WeeeTest.php @@ -220,7 +220,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -260,7 +260,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_taxable_unit_not_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -300,7 +300,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -340,7 +340,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_non_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -382,7 +382,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_non_taxable_unit_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_UNIT_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_UNIT_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -424,7 +424,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_taxable_row_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -464,7 +464,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_taxable_row_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -504,7 +504,7 @@ public function collectDataProvider() $data['price_incl_tax_weee_non_taxable_row_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => true, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -546,7 +546,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_non_taxable_row_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, @@ -588,7 +588,7 @@ public function collectDataProvider() $data['price_excl_tax_weee_non_taxable_row_not_included_in_subtotal'] = [ 'tax_config' => [ 'priceIncludesTax' => false, - 'getCalculationAgorithm' => Calculation::CALC_ROW_BASE, + 'getCalculationAlgorithm' => Calculation::CALC_ROW_BASE, ], 'weee_config' => [ 'isEnabled' => true, From e1e4dd6e5cd2018775d7943fcb271dc7fe0be1ec Mon Sep 17 00:00:00 2001 From: Mike Weis Date: Fri, 19 Dec 2014 11:29:00 -0600 Subject: [PATCH 03/18] MAGETWO-28380: Totals taxes sorting is different on order/invoice/refund create and view pages - fixed - updated unit test --- app/code/Magento/Tax/Helper/Data.php | 49 +++++++------ .../testsuite/Magento/Tax/Helper/DataTest.php | 70 +++++++++++++++++++ 2 files changed, 99 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index 26e3386435f47..a30fc64cc9608 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -682,17 +682,23 @@ public function getCalculatedTaxes($source) * 'tax_amount' => $taxAmount, * 'base_tax_amount' => $baseTaxAmount, * 'title' => $title, - * 'percent' => $percent + * 'percent' => $percent, + * 'type' => $type * ) * ) * * @param array $taxClassAmount * @param OrderTaxDetailsItemInterface $itemTaxDetail * @param float $ratio + * @param string $type * @return array */ - private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $itemTaxDetail, $ratio) - { + private function _aggregateTaxes( + $taxClassAmount, + OrderTaxDetailsItemInterface $itemTaxDetail, + $ratio, + $type = 'product' + ) { $itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes(); foreach ($itemAppliedTaxes as $itemAppliedTax) { $taxAmount = $itemAppliedTax->getAmount() * $ratio; @@ -705,6 +711,7 @@ private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $ if (!isset($taxClassAmount[$taxCode])) { $taxClassAmount[$taxCode]['title'] = $itemAppliedTax->getTitle(); $taxClassAmount[$taxCode]['percent'] = $itemAppliedTax->getPercent(); + $taxClassAmount[$taxCode]['type'] = $type; $taxClassAmount[$taxCode]['tax_amount'] = $taxAmount; $taxClassAmount[$taxCode]['base_tax_amount'] = $baseTaxAmount; } else { @@ -796,23 +803,6 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface $orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getId()); - // Apply any taxes for shipping - $shippingTaxAmount = $salesItem->getShippingTaxAmount(); - $originalShippingTaxAmount = $order->getShippingTaxAmount(); - if ($shippingTaxAmount && $originalShippingTaxAmount && - $shippingTaxAmount != 0 && floatval($originalShippingTaxAmount) - ) { - //An invoice or credit memo can have a different qty than its order - $shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount; - $itemTaxDetails = $orderTaxDetails->getItems(); - foreach ($itemTaxDetails as $itemTaxDetail) { - //Aggregate taxable items associated with shipping - if ($itemTaxDetail->getType() == \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING) { - $taxClassAmount = $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio); - } - } - } - // Apply any taxes for the items /** @var $item \Magento\Sales\Model\Order\Invoice\Item|\Magento\Sales\Model\Order\Creditmemo\Item */ foreach ($salesItem->getItems() as $item) { @@ -844,6 +834,25 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface } } + // Apply any taxes for shipping + $shippingType = \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING; + $shippingTaxAmount = $salesItem->getShippingTaxAmount(); + $originalShippingTaxAmount = $order->getShippingTaxAmount(); + if ($shippingTaxAmount && $originalShippingTaxAmount && + $shippingTaxAmount != 0 && floatval($originalShippingTaxAmount) + ) { + //An invoice or credit memo can have a different qty than its order + $shippingRatio = $shippingTaxAmount / $originalShippingTaxAmount; + $itemTaxDetails = $orderTaxDetails->getItems(); + foreach ($itemTaxDetails as $itemTaxDetail) { + //Aggregate taxable items associated with shipping + if ($itemTaxDetail->getType() == $shippingType) { + $taxClassAmount = + $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio, $shippingType); + } + } + } + return $taxClassAmount; } } diff --git a/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php index 01af7e215929c..6b01c6385e2eb 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php @@ -301,6 +301,7 @@ public function getCalculatedTaxesForOrderItemsDataProvider() 'percent' => 20.0, 'tax_amount' => 2.5, 'base_tax_amount' => 2.5, + 'type' => 'product', ], ], ], @@ -362,6 +363,75 @@ public function getCalculatedTaxesForOrderItemsDataProvider() 'percent' => 20.0, 'tax_amount' => 6.5, 'base_tax_amount' => 6.5, + 'type' => 'product', + ], + ], + ], + //Scenario 3: one item, with both shipping and product taxes + 'one_item_with_both_shipping_and_product_taxes' => [ + 'order' => [ + 'order_id' => 1, + 'shipping_tax_amount' => 2, + 'order_tax_details' => [ + 'items' => [ + 'shippingTax1' => [ + 'item_id' => null, + 'type' => 'shipping', + 'applied_taxes' => [ + [ + 'amount' => 2.0, + 'base_amount' => 2.0, + 'code' => 'US-CA-Ship', + 'title' => 'US-CA-Sales-Tax-Ship', + 'percent' => 10.0, + ], + ], + ], + 'itemTax1' => [ + 'item_id' => 1, + 'applied_taxes' => [ + [ + 'amount' => 5.0, + 'base_amount' => 5.0, + 'code' => 'US-CA', + 'title' => 'US-CA-Sales-Tax', + 'percent' => 20.0, + ], + ], + ], + ], + ], + ], + 'invoice' => [ + 'shipping_tax_amount' => 2, + 'invoice_items' => [ + 'item1' => new MagentoObject( + [ + 'order_item' => new MagentoObject( + [ + 'id' => 1, + 'tax_amount' => 5.00, + ] + ), + 'tax_amount' => 5.00, + ] + ), + ], + ], + 'expected_results' => [ + [ + 'title' => 'US-CA-Sales-Tax', + 'percent' => 20.0, + 'tax_amount' => 5.00, + 'base_tax_amount' => 5.00, + 'type' => 'product', + ], + [ + 'title' => 'US-CA-Sales-Tax-Ship', + 'percent' => 10.0, + 'tax_amount' => 2.00, + 'base_tax_amount' => 2.00, + 'type' => 'shipping', ], ], ], From d5ab0710c1ddcc23dfd1f517f743366dbdfa5091 Mon Sep 17 00:00:00 2001 From: Mike Weis Date: Fri, 19 Dec 2014 11:58:27 -0600 Subject: [PATCH 04/18] MAGETWO-30745: CsvImportHandler Tests still refer to links from Tax module instead of TaxImportExport Module - fixed --- .../Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php index 2f3fe5e8ca8fc..6d6515c6ed675 100644 --- a/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/TaxImportExport/Model/Rate/CsvImportHandlerTest.php @@ -7,7 +7,7 @@ class CsvImportHandlerTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Tax\Model\Rate\CsvImportHandler + * @var \Magento\TaxImportExport\Model\Rate\CsvImportHandler */ protected $_importHandler; From 51b74d14eee2ff8e383e9e6d755ab87d9fdf889b Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Thu, 25 Dec 2014 18:46:45 +0200 Subject: [PATCH 05/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - Added test to new repo --- .../Catalog/Test/Block/Product/Price.php | 10 +- .../GroupPriceOptions.php | 2 + .../Test/TestStep/CreateProductStep.php | 3 +- .../Test/Repository/CatalogRule.php | 11 + .../Test/TestStep/CreateCatalogRuleStep.php | 64 +++++ .../Checkout/Test/Block/Cart/CartItem.php | 34 ++- .../Checkout/Test/Block/Cart/Totals.php | 59 ++-- ...axCalculationAfterCheckoutDownloadable.php | 73 +++++ ...axRuleIsAppliedToAllPricesDownloadable.php | 71 +++++ ...ckoutDownloadableExcludingIncludingTax.php | 62 +++++ ...nAfterCheckoutDownloadableExcludingTax.php | 65 +++++ ...nAfterCheckoutDownloadableIncludingTax.php | 62 +++++ ...ricesDownloadableExcludingIncludingTax.php | 72 +++++ ...iedToAllPricesDownloadableExcludingTax.php | 73 +++++ ...iedToAllPricesDownloadableIncludingTax.php | 72 +++++ .../Fixture/DownloadableProductInjectable.php | 2 +- .../CheckoutData.php | 17 ++ .../GroupPriceOptions.php | 42 +++ .../DownloadableProductInjectable.php | 60 ++++ .../DownloadableTaxCalculationTest.php | 35 +++ .../DownloadableTaxCalculationTest/test.csv | 17 ++ .../Downloadable/Test/etc/constraint.xml | 27 ++ .../Downloadable/Test/etc/scenario.xml | 36 +++ .../Adminhtml/Order/AbstractForm/Product.php | 86 ++++++ .../Adminhtml/Order/AbstractForm/Totals.php | 210 ++++++++++++++ .../Sales/Test/Block/Adminhtml/Order/Grid.php | 7 + .../Block/Adminhtml/Order/Invoice/Form.php | 2 +- .../Block/Adminhtml/Order/Invoice/Totals.php | 3 +- .../Test/Block/Adminhtml/Order/Totals.php | 37 +-- .../Test/Block/Adminhtml/Order/View/Items.php | 94 +++++++ .../Magento/Sales/Test/Block/Order/View.php | 256 ++++++++++++++++++ .../Page/Adminhtml/OrderCreditMemoNew.xml | 5 + .../AbstractAssertOrderTaxOnBackend.php | 206 ++++++++++++++ ...tractAssertTaxCalculationAfterCheckout.php | 157 +++++++++++ ...ractAssertTaxRuleIsAppliedToAllPrices.php} | 141 +++------- ...stractAssertTaxWithCrossBorderApplying.php | 2 +- ...OrderTaxOnBackendExcludingIncludingTax.php | 89 ++++++ .../AssertOrderTaxOnBackendExcludingTax.php | 91 +++++++ .../AssertOrderTaxOnBackendIncludingTax.php | 89 ++++++ ...tionAfterCheckoutExcludingIncludingTax.php | 62 +++++ ...axCalculationAfterCheckoutExcludingTax.php | 63 +++++ ...axCalculationAfterCheckoutIncludingTax.php | 62 +++++ ...ppliedToAllPricesExcludingIncludingTax.php | 73 +++++ ...axRuleIsAppliedToAllPricesExcludingTax.php | 73 +++++ ...axRuleIsAppliedToAllPricesIncludingTax.php | 73 +++++ .../Tax/Test/TestStep/CreateTaxRuleStep.php | 65 +++++ .../app/Magento/Tax/Test/etc/constraint.xml | 27 ++ .../app/Magento/Tax/Test/etc/scenario.xml | 39 +++ 48 files changed, 2794 insertions(+), 187 deletions(-) create mode 100644 dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv create mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml create mode 100644 dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Totals.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php rename dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/{AssertTaxRuleIsAppliedToAllPrices.php => AbstractAssertTaxRuleIsAppliedToAllPrices.php} (54%) create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesIncludingTax.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php create mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php index 10a1c191bd1dc..0b74cb899d915 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Price.php @@ -293,21 +293,23 @@ protected function escape($price, $currency = '$') * Get price excluding tax * * @param string $currency - * @return string + * @return string|null */ public function getPriceExcludingTax($currency = '$') { - return trim($this->_rootElement->find($this->priceExcludingTax)->getText(), $currency); + $priceElement = $this->_rootElement->find($this->priceExcludingTax); + return $priceElement->isVisible() ? trim($priceElement->getText(), $currency) : null; } /** * Get price including tax * * @param string $currency - * @return string + * @return string|null */ public function getPriceIncludingTax($currency = '$') { - return trim($this->_rootElement->find($this->priceIncludingTax)->getText(), $currency); + $priceElement = $this->_rootElement->find($this->priceIncludingTax); + return $priceElement->isVisible() ? trim($priceElement->getText(), $currency) : null; } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/GroupPriceOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/GroupPriceOptions.php index 7cfc80091db1f..9d22c52bed284 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/GroupPriceOptions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple/GroupPriceOptions.php @@ -68,6 +68,8 @@ public function getDataConfig() } /** + * Get preset array + * * @param string $name * @return mixed|null */ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/CreateProductStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/CreateProductStep.php index 7d173332e1b71..453b3c7f87595 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/CreateProductStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/CreateProductStep.php @@ -54,7 +54,6 @@ public function run() if ($product->hasData('id') === false) { $product->persist(); } - - return ['product' => $product]; + return ['product' => $product]; } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Repository/CatalogRule.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Repository/CatalogRule.php index b0ea023ce423f..1576f4e5e4643 100755 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Repository/CatalogRule.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Repository/CatalogRule.php @@ -87,5 +87,16 @@ public function __construct(array $defaultConfig = [], array $defaultData = []) 'simple_action' => 'By Fixed Amount', 'discount_amount' => '10', ]; + + $this->_data['catalog_price_rule_all_groups'] = [ + 'name' => 'catalog_price_rule_all_groups_%isolation%', + 'description' => '-50% of price, Priority = 0', + 'is_active' => 'Active', + 'website_ids' => ['Main Website'], + 'customer_group_ids' => ['NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'], + 'sort_order' => '0', + 'simple_action' => 'By Percentage of the Original Price', + 'discount_amount' => '50', + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php new file mode 100644 index 0000000000000..f0c087db7ab05 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php @@ -0,0 +1,64 @@ +fixtureFactory = $fixtureFactory; + $this->catalogRule = $catalogRule; + } + + /** + * Create catalog rule + * + * @return array + */ + public function run() + { + $result['catalogRule'] = null; + if ($this->catalogRule != '-') { + $catalogRule = $this->fixtureFactory->createByCode( + 'catalogRule', + ['dataSet' => $this->catalogRule] + ); + $catalogRule->persist(); + $result['catalogRule'] = $catalogRule; + } + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php index c16fd46bb9660..57d4fd6ad3119 100755 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/CartItem.php @@ -68,23 +68,27 @@ public function getProductName() /** * Get product price * - * @return string + * @return string|null */ public function getPrice() { - $cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH)->getText(); - return str_replace(',', '', $this->escapeCurrency($cartProductPrice)); + $cartProductPrice = $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH); + return $cartProductPrice->isVisible() + ? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText())) + : null; } /** * Get product price including tax * - * @return string + * @return string|null */ public function getPriceInclTax() { - $cartProductPrice = $this->_rootElement->find($this->priceInclTax, Locator::SELECTOR_XPATH)->getText(); - return str_replace(',', '', $this->escapeCurrency($cartProductPrice)); + $cartProductPrice = $this->_rootElement->find($this->priceInclTax, Locator::SELECTOR_XPATH); + return $cartProductPrice->isVisible() + ? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText())) + : null; } /** @@ -111,29 +115,33 @@ public function getQty() /** * Get sub-total for the specified item in the cart * - * @return string + * @return string|null */ public function getSubtotalPrice() { - $price = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH)->getText(); - return str_replace(',', '', $this->escapeCurrency($price)); + $cartProductPrice = $this->_rootElement->find($this->subtotalPrice, Locator::SELECTOR_XPATH); + return $cartProductPrice->isVisible() + ? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText())) + : null; } /** * Get sub-total including tax for the specified item in the cart * - * @return string + * @return string|null */ public function getSubtotalPriceInclTax() { - $price = $this->_rootElement->find($this->subTotalPriceInclTax, Locator::SELECTOR_XPATH)->getText(); - return str_replace(',', '', $this->escapeCurrency($price)); + $cartProductPrice = $this->_rootElement->find($this->subTotalPriceInclTax, Locator::SELECTOR_XPATH); + return $cartProductPrice->isVisible() + ? str_replace(',', '', $this->escapeCurrency($cartProductPrice->getText())) + : null; } /** * Get product options in the cart * - * @return string + * @return array */ public function getOptions() { diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php index a9db2d568234b..8c5951628156f 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php @@ -75,7 +75,7 @@ class Totals extends Block * * @var string */ - protected $discount = '//tr[normalize-space(th)="Discount"]//span'; + protected $discount = '[class=totals] .amount .price'; /** * Get shipping price including tax selector @@ -94,45 +94,45 @@ class Totals extends Block /** * Get Grand Total Text * - * @return array|string + * @return string */ public function getGrandTotal() { - $grandTotal = $this->_rootElement->find($this->grandTotal)->getText(); + $grandTotal = $this->_rootElement->find($this->grandTotal, Locator::SELECTOR_CSS)->getText(); return $this->escapeCurrency($grandTotal); } /** * Get Grand Total Text * - * @return string + * @return string|null */ public function getGrandTotalIncludingTax() { - $grandTotal = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($grandTotal); + $priceElement = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** * Get Grand Total Text * - * @return string + * @return string|null */ public function getGrandTotalExcludingTax() { - $grandTotal = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($grandTotal); + $priceElement = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** * Get Tax text from Order Totals * - * @return array|string + * @return string|null */ public function getTax() { - $taxPrice = $this->_rootElement->find($this->tax, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($taxPrice); + $priceElement = $this->_rootElement->find($this->tax, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** @@ -152,37 +152,37 @@ public function isTaxVisible() */ public function getSubtotal() { - $subTotal = $this->_rootElement->find($this->subtotal)->getText(); + $subTotal = $this->_rootElement->find($this->subtotal, Locator::SELECTOR_CSS)->getText(); return $this->escapeCurrency($subTotal); } /** * Get Subtotal text * - * @return string + * @return string|null */ public function getSubtotalIncludingTax() { - $subTotal = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($subTotal); + $priceElement = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** * Get Subtotal text * - * @return string + * @return string|null */ public function getSubtotalExcludingTax() { - $subTotal = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($subTotal); + $priceElement = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** * Method that escapes currency symbols * * @param string $price - * @return string + * @return string|null */ protected function escapeCurrency($price) { @@ -193,35 +193,34 @@ protected function escapeCurrency($price) /** * Get discount * - * @return string + * @return string|null */ public function getDiscount() { - $discount = $this->_rootElement->find($this->discount, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($discount); + $priceElement = $this->_rootElement->find($this->discount, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** * Get shipping price * - * @return string + * @return string|null */ public function getShippingPrice() { - $shippingPrice = $this->_rootElement->find($this->shippingPriceSelector, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($shippingPrice); + $priceElement = $this->_rootElement->find($this->shippingPriceSelector, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** * Get shipping price * - * @return string + * @return string|null */ public function getShippingPriceInclTax() { - $shippingPrice = $this->_rootElement - ->find($this->shippingPriceInclTaxSelector, Locator::SELECTOR_CSS)->getText(); - return $this->escapeCurrency($shippingPrice); + $priceElement = $this->_rootElement->find($this->shippingPriceInclTaxSelector, Locator::SELECTOR_CSS); + return $priceElement->isVisible() ? $this->escapeCurrency($priceElement->getText()) : null; } /** diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php new file mode 100644 index 0000000000000..7bc83be16a65f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php @@ -0,0 +1,73 @@ +checkoutOnepage = $checkoutOnepage; + $this->orderView = $orderView; + + $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout(); + $checkoutOnepage->getBillingBlock()->clickContinue(); + $checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod(['method' => 'check_money_order']); + $checkoutOnepage->getPaymentMethodsBlock()->clickContinue(); + $actualPrices = []; + $actualPrices = $this->getReviewPrices($actualPrices, $product); + $actualPrices = $this->getReviewTotals($actualPrices); + $prices = $this->preparePrices($prices); + //Order review prices verification + $message = 'Prices on order review should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + + $checkoutOnepage->getReviewBlock()->placeOrder(); + $checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); + $checkoutOnepageSuccess->getSuccessBlock()->openOrder(); + $actualPrices = []; + $actualPrices = $this->getOrderPrices($actualPrices, $product); + $actualPrices = $this->getOrderTotals($actualPrices); + + //Frontend order prices verification + $message = 'Prices on order view page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php new file mode 100644 index 0000000000000..6075d98c4c5a5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php @@ -0,0 +1,71 @@ +cmsIndex = $cmsIndex; + $this->catalogCategoryView = $catalogCategoryView; + $this->catalogProductView = $catalogProductView; + $this->checkoutCart = $checkoutCart; + $actualPrices = []; + //Assertion steps + $productName = $product->getName(); + $productCategory = $product->getCategoryIds()[0]; + $this->openCategory($productCategory); + $actualPrices = $this->getCategoryPrices($productName, $actualPrices); + $catalogCategoryView->getListProductBlock()->openProductViewPage($productName); + $catalogProductView->getViewBlock()->fillOptions($product); + $actualPrices = $this->getProductPagePrices($actualPrices); + $catalogProductView->getViewBlock()->clickAddToCart(); + $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); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php new file mode 100644 index 0000000000000..a686bf97175fa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php @@ -0,0 +1,62 @@ +checkoutOnepage->getReviewBlock(); + $actualPrices['subtotal_excl_tax'] = $reviewBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $reviewBlock->getSubtotalInclTax(); + $actualPrices['discount'] = $reviewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $reviewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $reviewBlock->getShippingInclTax(); + $actualPrices['tax'] = $reviewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $reviewBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $reviewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get order totals. + * + * @param $actualPrices + * @return array + */ + public function getOrderTotals($actualPrices) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['subtotal_excl_tax'] = $viewBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $viewBlock->getSubtotalInclTax(); + $actualPrices['discount'] = $viewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = $viewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php new file mode 100644 index 0000000000000..6244b27448f86 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php @@ -0,0 +1,65 @@ +checkoutOnepage->getReviewBlock(); + $actualPrices['subtotal_excl_tax'] = $reviewBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + $actualPrices['discount'] = $reviewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $reviewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $reviewBlock->getShippingInclTax(); + $actualPrices['tax'] = $reviewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $reviewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get order totals. + * + * @param $actualPrices + * @return array + */ + public function getOrderTotals($actualPrices) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['subtotal_excl_tax'] = $viewBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + + $actualPrices['discount'] = $viewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php new file mode 100644 index 0000000000000..65bef8f5c92dc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php @@ -0,0 +1,62 @@ +checkoutOnepage->getReviewBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $reviewBlock->getSubtotal(); + $actualPrices['discount'] = $reviewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $reviewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $reviewBlock->getShippingInclTax(); + $actualPrices['tax'] = $reviewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $reviewBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $reviewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get order totals. + * + * @param $actualPrices + * @return array + */ + public function getOrderTotals($actualPrices) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $viewBlock->getSubtotal(); + $actualPrices['discount'] = $viewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = $viewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php new file mode 100644 index 0000000000000..4882be0464281 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php @@ -0,0 +1,72 @@ +catalogCategoryView->getListProductBlock()->getProductPriceBlock($productName); + $actualPrices['category_price_excl_tax'] = $priceBlock->getPriceExcludingTax(); + $actualPrices['category_price_incl_tax'] = $priceBlock->getPriceIncludingTax(); + + return $actualPrices; + } + + /** + * Get product view prices. + * + * @param array $actualPrices + * @return array + */ + public function getProductPagePrices($actualPrices) + { + $viewBlock = $this->catalogProductView->getViewBlock(); + $actualPrices['product_view_price_excl_tax'] = $viewBlock->getProductPriceExcludingTax(); + $actualPrices['product_view_price_incl_tax'] = $viewBlock->getProductPriceIncludingTax(); + + return $actualPrices; + } + + /** + * Get totals. + * + * @param $actualPrices + * @return array + */ + public function getTotals($actualPrices) + { + $totalsBlock = $this->checkoutCart->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotalExcludingTax(); + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotalIncludingTax(); + $actualPrices['discount'] = $totalsBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingPrice(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingPriceInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExcludingTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalIncludingTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php new file mode 100644 index 0000000000000..d22ef9970238a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php @@ -0,0 +1,73 @@ +catalogCategoryView->getListProductBlock()->getProductPriceBlock($productName); + $actualPrices['category_price_excl_tax'] = $priceBlock->getEffectivePrice(); + $actualPrices['category_price_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get product view prices. + * + * @param array $actualPrices + * @return array + */ + public function getProductPagePrices($actualPrices) + { + $viewBlock = $this->catalogProductView->getViewBlock(); + $actualPrices['product_view_price_excl_tax'] = $viewBlock->getPriceBlock()->getEffectivePrice(); + $actualPrices['product_view_price_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get totals. + * + * @param $actualPrices + * @return array + */ + public function getTotals($actualPrices) + { + $totalsBlock = $this->checkoutCart->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + $actualPrices['discount'] = $totalsBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingPrice(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingPriceInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php new file mode 100644 index 0000000000000..3c8240990191f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php @@ -0,0 +1,72 @@ +catalogCategoryView->getListProductBlock()->getProductPriceBlock($productName); + $actualPrices['category_price_excl_tax'] = null; + $actualPrices['category_price_incl_tax'] = $priceBlock->getEffectivePrice(); + + return $actualPrices; + } + + /** + * Get product view prices. + * + * @param array $actualPrices + * @return array + */ + public function getProductPagePrices($actualPrices) + { + $viewBlock = $this->catalogProductView->getViewBlock(); + $actualPrices['product_view_price_excl_tax'] = null; + $actualPrices['product_view_price_incl_tax'] = $viewBlock->getPriceBlock()->getEffectivePrice(); + + return $actualPrices; + } + + /** + * Get totals. + * + * @param $actualPrices + * @return array + */ + public function getTotals($actualPrices) + { + $totalsBlock = $this->checkoutCart->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotal(); + $actualPrices['discount'] = $totalsBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingPrice(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingPriceInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExcludingTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalIncludingTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php index 1e61caaeb5e3f..1776aee3b32ad 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable.php @@ -143,7 +143,7 @@ class DownloadableProductInjectable extends InjectableFixture 'default_value' => '', 'input' => 'text', 'group' => 'advanced-pricing', - 'source' => 'Magento\Catalog\Test\Fixture\CatalogProductSimple\GroupPriceOptions', + 'source' => '\Magento\Downloadable\Test\Fixture\DownloadableProductInjectable\GroupPriceOptions' ]; protected $has_options = [ diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php index 46d459335b36e..5ee427ea18e32 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/CheckoutData.php @@ -79,6 +79,23 @@ protected function getPreset($name) ], ], ], + + 'one_custom_option_and_downloadable_link' => [ + 'options' => [ + 'custom_options' => [ + [ + 'title' => 'attribute_key_0', + 'value' => 'option_key_0' + ], + ], + 'links' => [ + [ + 'label' => 'link_1', + 'value' => 'Yes' + ] + ], + ] + ], ]; return isset($presets[$name]) ? $presets[$name] : []; } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php new file mode 100644 index 0000000000000..14a1482d9390b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php @@ -0,0 +1,42 @@ + [ + [ + 'price' => 20.00, + 'website' => 'All Websites [USD]', + 'customer_group' => 'General', + ], + ], + ]; + if (!isset($presets[$name])) { + return null; + } + return $presets[$name]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php index 65b604c6bb427..53f2d5dc8045c 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php @@ -73,5 +73,65 @@ public function __construct(array $defaultConfig = [], array $defaultData = []) 'downloadable_links' => ['preset' => 'with_two_separately_links'], 'checkout_data' => ['preset' => 'with_two_bought_links'], ]; + $this->_data['with_two_separately_links_special_price_and_category'] = [ + 'name' => 'Downloadable product %isolation%', + 'sku' => 'downloadable_product_%isolation%', + 'type_id' => 'downloadable', + 'url_key' => 'downloadable-product-%isolation%', + 'price' => ['value' => '30'], + 'special_price' => '20', + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'quantity_and_stock_status' => [ + 'qty' => 1111, + 'is_in_stock' => 'In Stock' + ], + 'status' => 'Product online', + 'category_ids' => ['presets' => 'default'], + 'visibility' => 'Catalog, Search', + 'is_virtual' => 'Yes', + 'website_ids' => ['Main Website'], + 'downloadable_links' => ['preset' => 'with_two_separately_links'], + 'checkout_data' => ['preset' => 'with_two_separately_links'] + ]; + $this->_data['with_two_separately_links_group_price_and_category'] = [ + 'name' => 'Downloadable product %isolation%', + 'sku' => 'downloadable_product_%isolation%', + 'type_id' => 'downloadable', + 'url_key' => 'downloadable-product-%isolation%', + 'price' => ['value' => '30'], + 'group_price' => ['preset' => 'downloadable_with_tax'], + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'quantity_and_stock_status' => [ + 'qty' => 1111, + 'is_in_stock' => 'In Stock' + ], + 'status' => 'Product online', + 'category_ids' => ['presets' => 'default'], + 'visibility' => 'Catalog, Search', + 'is_virtual' => 'Yes', + 'website_ids' => ['Main Website'], + 'downloadable_links' => ['preset' => 'with_two_separately_links'], + 'checkout_data' => ['preset' => 'with_two_separately_links'] + ]; + $this->_data['with_two_separately_links_custom_options_and_category'] = [ + 'name' => 'Downloadable product %isolation%', + 'sku' => 'downloadable_product_%isolation%', + 'type_id' => 'downloadable', + 'url_key' => 'downloadable-product-%isolation%', + 'price' => ['value' => '20'], + 'tax_class_id' => ['dataSet' => 'Taxable Goods'], + 'quantity_and_stock_status' => [ + 'qty' => 1111, + 'is_in_stock' => 'In Stock' + ], + 'status' => 'Product online', + 'category_ids' => ['presets' => 'default'], + 'visibility' => 'Catalog, Search', + 'is_virtual' => 'Yes', + 'website_ids' => ['Main Website'], + 'custom_options' => ['preset' => 'drop_down_with_one_option_percent_price'], + 'downloadable_links' => ['preset' => 'with_two_separately_links'], + 'checkout_data' => ['preset' => 'one_custom_option_and_downloadable_link'] + ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php new file mode 100644 index 0000000000000..bc7d8f9327e65 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php @@ -0,0 +1,35 @@ + Taxes > Tax Rules. + * 3. Click 'Add New Tax Rule' button. + * 4. Assign default rates to rule. + * 5. Save Tax Rate. + * 6. Go to Products > Catalog. + * 7. Add new product. + * 8. Fill data according to dataset. + * 9. Save product. + * 10. Go to Stores > Configuration. + * 11. Fill Tax configuration according to data set. + * 12. Save tax configuration. + * 13. Perform all assertions. + * + * @group Tax_(CS) + * @ZephyrId MAGETWO-32076 + */ +class DownloadableTaxCalculationTest extends TaxCalculationTest +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv new file mode 100644 index 0000000000000..b173ea5f5a2f1 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv @@ -0,0 +1,17 @@ +"description";"configData";"product";"salesRule";"catalogRule";"taxRule";"customer/dataSet";"qty";"prices/category_price_excl_tax";"prices/category_price_incl_tax";"prices/product_view_price_excl_tax";"prices/product_view_price_incl_tax";"prices/cart_item_price_excl_tax";"prices/cart_item_price_incl_tax";"prices/cart_item_subtotal_excl_tax";"prices/cart_item_subtotal_incl_tax";"prices/subtotal_excl_tax";"prices/subtotal_incl_tax";"prices/discount";"prices/shipping_excl_tax";"prices/shipping_incl_tax";"prices/tax";"prices/grand_total_excl_tax";"prices/grand_total_incl_tax";"constraint";"issue" +"Downloadable product with sales rule, customer tax equals store tax and catalog price excluding tax";"total_cat_excl_ship_incl_after_disc_on_incl_disp_exin";"downloadableProductInjectable::with_two_separately_links_special_price_and_category";"active_sales_rule_for_all_groups_no_coupon";"-";"customer_equals_store_rate";"johndoe_unique";"-";"20.00";"21.65";"23.00";"24.90";"23.00";"24.90";"23.00";"24.90";"23.00";"24.90";"12.45";"";"";"0.87";"10.55";"11.42";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax, assertOrderTaxOnBackendExcludingIncludingTax";"MAGETWO-32057" +"Downloadable product with catalog rule, customer tax greater than store tax and catalog price excluding tax";"total_cat_excl_ship_incl_after_disc_on_incl_disp_incl";"downloadableProductInjectable::with_two_separately_links_special_price_and_category";"-";"catalog_price_rule_all_groups";"customer_greater_store_rate";"johndoe_unique";"-";"";"16.26";"";"19.51";"";"19.51";"";"19.51";"";"19.51";"";"";"";"1.51";"18.00";"19.51";"assertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax, assertTaxCalculationAfterCheckoutDownloadableIncludingTax, assertOrderTaxOnBackendIncludingTax";"" +"Downloadable product with sales rule, customer tax less than store tax and catalog price excluding tax";"total_cat_excl_ship_incl_after_disc_on_incl_disp_excl";"downloadableProductInjectable::with_two_separately_links_group_price_and_category";"active_sales_rule_for_all_groups_no_coupon";"-";"customer_less_store_rate";"johndoe_unique";"-";"20.00";"";"23.00";"";"23.00";"";"23.00";"";"23.00";"";"12.45";"";"";"0.87";"11.42";"";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingTax, assertOrderTaxOnBackendExcludingTax";"" +"Downloadable product with catalog rule, customer tax greater than store tax and catalog price including tax";"total_cat_incl_ship_excl_before_disc_on_excl_disp_exin";"downloadableProductInjectable::with_two_separately_links_custom_options_and_category";"-";"catalog_price_rule_all_groups";"customer_greater_store_rate";"johndoe_unique";"-";"9.24";"10.01";"12.01";"13.01";"12.01";"13.02";"12.01";"13.02";"12.01";"13.02";"";"";"";"1.01";"12.01";"13.02";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax, assertOrderTaxOnBackendExcludingIncludingTax";"MAGETWO-32057" +"Downloadable product with sales rule, customer tax less than store tax and catalog price including tax";"total_cat_incl_ship_excl_before_disc_on_excl_disp_incl";"downloadableProductInjectable::with_two_separately_links_group_price_and_category";"active_sales_rule_for_all_groups_no_coupon";"-";"customer_less_store_rate";"johndoe_unique";"-";"";"19.98";"";"22.98";"";"22.97";"";"22.97";"";"22.97";"10.61";"";"";"1.75";"10.61";"12.36";"assertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax, assertTaxCalculationAfterCheckoutDownloadableIncludingTax, assertOrderTaxOnBackendIncludingTax";"" +"Downloadable product with catalog rule, customer tax equals store tax and catalog price including tax";"total_cat_incl_ship_excl_before_disc_on_excl_disp_excl";"downloadableProductInjectable::with_two_separately_links_custom_options_and_category";"-";"catalog_price_rule_all_groups";"customer_equals_store_rate";"johndoe_unique";"-";"9.24";"";"12.01";"";"12.01";"";"12.01";"";"12.01";"";"";"";"";"0.99";"13.00";"";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingTax, assertOrderTaxOnBackendExcludingTax";"MAGETWO-32057" + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/constraint.xml index b10f5bbe51463..d3a31c7be160a 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/constraint.xml @@ -25,4 +25,31 @@ low + + high + + + high + + + high + + + high + + + high + + + high + + + high + + + high + + + high + diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml new file mode 100644 index 0000000000000..ce97ab96f36ed --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml @@ -0,0 +1,36 @@ + + + + + + + + setupConfiguration + + createSalesRule + + + createCatalogRule + + + createTaxRule + + + createProduct + + + createCustomer + + + loginCustomerOnFrontend + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Product.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Product.php index cae80b47c510a..afdc7c0ed9fd6 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Product.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Product.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm; use Mtf\Block\Form; +use Mtf\Client\Element\Locator; /** * Class Product @@ -13,6 +14,91 @@ */ class Product extends Form { + /** + * Product price excluding tax search mask + * + * @var string + */ + protected $itemExclTax = '//td[@class="col-price"]/div[@class="price-excl-tax"]/span[@class="price"]'; + + /** + * Product price including tax search mask + * + * @var string + */ + protected $itemInclTax = '//td[@class="col-price"]/div[@class="price-incl-tax"]/span[@class="price"]'; + + /** + * Product price subtotal excluding tax search mask + * + * @var string + */ + protected $itemSubExclTax = '//td[@class="col-subtotal"]/div[@class="price-excl-tax"]/span[@class="price"]'; + + /** + * Product price subtotal including tax search mask + * + * @var string + */ + protected $itemSubInclTax = '//td[@class="col-subtotal"]/div[@class="price-incl-tax"]/span[@class="price"]'; + + /** + * Get Item price excluding tax + * + * @return string|null + */ + public function getItemPriceExclTax() + { + $price = $this->_rootElement->find($this->itemExclTax, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price including tax + * + * @return string|null + */ + public function getItemPriceInclTax() + { + $price = $this->_rootElement->find($this->itemInclTax, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @return string|null + */ + public function getItemSubExclTax() + { + $price = $this->_rootElement->find($this->itemSubExclTax, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @return string|null + */ + + public function getItemSubInclTax() + { + $price = $this->_rootElement->find($this->itemSubInclTax, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Method that escapes currency symbols + * + * @param string $price + * @return string|null + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } + /** * Fill item product data * diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Totals.php new file mode 100644 index 0000000000000..e1e57b8961f35 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Totals.php @@ -0,0 +1,210 @@ +_rootElement->find($this->grandTotal, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Grand Total Excluding Tax Text + * + * @return string + */ + public function getGrandTotalExclTax() + { + $grandTotal = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Grand Total Including Tax Text + * + * @return string + */ + public function getGrandTotalInclTax() + { + $grandTotal = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Tax text from Order Totals + * + * @return string + */ + public function getTax() + { + $tax = $this->_rootElement->find($this->tax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($tax); + } + + /** + * Get Tax text from Order Totals + * + * @return string|null + */ + public function getDiscount() + { + $discount = $this->_rootElement->find($this->discount, Locator::SELECTOR_XPATH); + return $discount->isVisible() ? $this->escapeCurrency($discount->getText()) : null; + } + + /** + * Get Subtotal text + * + * @return string + */ + public function getSubtotal() + { + $subTotal = $this->_rootElement->find($this->subtotal, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Subtotal text + * + * @return string + */ + public function getSubtotalExclTax() + { + $subTotal = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Subtotal text + * + * @return string + */ + public function getSubtotalInclTax() + { + $subTotal = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Shipping Excluding tax price text + * + * @return string|null + */ + public function getShippingInclTax() + { + $subTotal = $this->_rootElement->find($this->shippingInclTax, Locator::SELECTOR_XPATH); + return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; + } + + /** + * Get Shipping Including tax price text + * + * @return string|null + */ + public function getShippingExclTax() + { + $subTotal = $this->_rootElement->find($this->shippingExclTax, Locator::SELECTOR_XPATH); + return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; + } + + /** + * Method that escapes currency symbols + * + * @param string $price + * @return string|null + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php index d3bd69d03a003..3ffa76d1e472c 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php @@ -42,6 +42,13 @@ class Grid extends GridInterface */ protected $editLink = 'td[class*=col-action] a'; + /** + * First row selector + * + * @var string + */ + protected $firstRowSelector = '//tbody/tr[1]//a'; + /** * {@inheritdoc} */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php index d7931b7c648c1..586ce942ea4c5 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form.php @@ -26,7 +26,7 @@ class Form extends AbstractForm * * @return Items */ - protected function getItemsBlock() + public function getItemsBlock() { return $this->blockFactory->create( 'Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items', diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php index 32f2d54254ca2..819c75229fa79 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php @@ -5,14 +5,13 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Invoice; -use Mtf\Block\Block; use Mtf\Client\Element\Locator; /** * Class Totals * Invoice totals block */ -class Totals extends Block +class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Totals { /** * Submit invoice button selector diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php index cff130c94a37a..88b5b445d3ff3 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php @@ -5,43 +5,10 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order; -use Mtf\Block\Block; -use Mtf\Client\Element\Locator; - /** - * Class Totals * Order totals block - * */ -class Totals extends Block +class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Totals { - /** - * Grand total search mask - * - * @var string - */ - protected $grandTotal = '//tr[normalize-space(td)="Grand Total"]//span'; - - /** - * Get Grand Total Text - * - * @return array|string - */ - public function getGrandTotal() - { - $grandTotal = $this->_rootElement->find($this->grandTotal, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($grandTotal); - } - - /** - * Method that escapes currency symbols - * - * @param string $price - * @return string|null - */ - protected function escapeCurrency($price) - { - preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); - return (isset($matches[1])) ? $matches[1] : null; - } + // } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Items.php index d70210c7c11f3..85b4c41ee0932 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Items.php @@ -23,6 +23,36 @@ class Items extends Block */ protected $priceSelector = '//div[@class="price-excl-tax"]//span[@class="price"]'; + // @codingStandardsIgnoreStart + /** + * Product price excluding tax search mask + * + * @var string + */ + protected $itemExclTax = '//tr[contains (.,"%s")]/td[@class="col-price"]/div[@class="price-excl-tax"]/span[@class="price"]'; + + /** + * Product price including tax search mask + * + * @var string + */ + protected $itemInclTax = '//tr[contains (.,"%s")]/td[@class="col-price"]/div[@class="price-incl-tax"]/span[@class="price"]'; + + /** + * Product price subtotal excluding tax search mask + * + * @var string + */ + protected $itemSubExclTax = '//tr[contains (.,"%s")]/td[@class="col-subtotal"]/div[@class="price-excl-tax"]/span[@class="price"]'; + + /** + * Product price subtotal including tax search mask + * + * @var string + */ + protected $itemSubInclTax = '//tr[contains (.,"%s")]/td[@class="col-subtotal"]/div[@class="price-incl-tax"]/span[@class="price"]'; + // @codingStandardsIgnoreEnd + /** * Returns the item price for the specified product. * @@ -52,4 +82,68 @@ public function getPrice(Product $product) return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText(); } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemPriceExclTax($productName) + { + $locator = sprintf($this->itemExclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price including tax + * + * @param string $productName + * @return string|null + */ + public function getItemPriceInclTax($productName) + { + $locator = sprintf($this->itemInclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemSubExclTax($productName) + { + $locator = sprintf($this->itemSubExclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemSubInclTax($productName) + { + $locator = sprintf($this->itemSubInclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Method that escapes currency symbols + * + * @param string $price + * @return string|null + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php index cb7a16398d871..e230d1ab36800 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php @@ -35,6 +35,99 @@ class View extends Block */ protected $link = '//*[contains(@class,"order-links")]//a[normalize-space(.)="%s"]'; + /** + * Grand total search mask + * + * @var string + */ + protected $grandTotal = '.grand_total span'; + + /** + * Grand total including tax search mask + * + * @var string + */ + protected $grandTotalInclTax = '.grand_total_incl span'; + + /** + * Subtotal search mask + * + * @var string + */ + protected $subtotal = '.subtotal .amount span'; + + /** + * Subtotal excluding tax search mask + * + * @var string + */ + protected $subtotalExclTax = '.subtotal_excl span'; + + /** + * Subtotal including tax search mask + * + * @var string + */ + protected $subtotalInclTax = '.subtotal_incl span'; + + /** + * Tax search mask + * + * @var string + */ + protected $tax = '.totals-tax span'; + + /** + * Discount search mask + * + * @var string + */ + protected $discount = '.discount span'; + + /** + * Shipping search mask + * + * @var string + */ + protected $shippingExclTax = '.shipping span'; + + /** + * Shipping search mask + * + * @var string + */ + protected $shippingInclTax = '.shipping_incl span'; + + /** + * Product price excluding tax search mask + * + * @var string + */ + protected $itemExclTax = '//tr[contains (.,"%s")]/td[@class="col price"]/span[@class="price-excluding-tax"]/span'; + + /** + * Product price including tax search mask + * + * @var string + */ + protected $itemInclTax = '//tr[contains (.,"%s")]/td[@class="col price"]/span[@class="price-including-tax"]/span'; + + // @codingStandardsIgnoreStart + /** + * Product price subtotal excluding tax search mask + * + * @var string + */ + protected $itemSubExclTax = '//tr[contains (.,"%s")]/td[@class="col subtotal"]/span[@class="price-excluding-tax"]/span'; + + /** + * Product price subtotal including tax search mask + * + * @var string + */ + protected $itemSubInclTax = '//tr[contains (.,"%s")]/td[@class="col subtotal"]/span[@class="price-including-tax"]/span'; + // @codingStandardsIgnoreEnd + /** * Get item block * @@ -60,4 +153,167 @@ public function openLinkByName($name) { $this->_rootElement->find(sprintf($this->link, $name), Locator::SELECTOR_XPATH)->click(); } + + /** + * Get Grand Total Text + * + * @return string + */ + public function getGrandTotal() + { + $grandTotal = $this->_rootElement->find($this->grandTotal, Locator::SELECTOR_CSS)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemPriceExclTax($productName) + { + $locator = sprintf($this->itemExclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemPriceInclTax($productName) + { + $locator = sprintf($this->itemInclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemSubExclTax($productName) + { + $locator = sprintf($this->itemSubExclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Item price excluding tax + * + * @param string $productName + * @return string|null + */ + public function getItemSubInclTax($productName) + { + $locator = sprintf($this->itemSubInclTax, $productName); + $price = $this->_rootElement->find($locator, Locator::SELECTOR_XPATH); + return $price->isVisible() ? $this->escapeCurrency($price->getText()) : null; + } + + /** + * Get Grand Total Text + * + * @return string|null + */ + public function getGrandTotalInclTax() + { + $grandTotal = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_CSS)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Tax text from Order Totals + * + * @return string + */ + public function getTax() + { + $tax = $this->_rootElement->find($this->tax, Locator::SELECTOR_CSS)->getText(); + return $this->escapeCurrency($tax); + } + + /** + * Get Tax text from Order Totals + * + * @return string|null + */ + public function getDiscount() + { + $discount = $this->_rootElement->find($this->discount, Locator::SELECTOR_CSS); + return $discount->isVisible() ? $this->escapeCurrency($discount->getText()) : null; + } + + /** + * Get Subtotal text + * + * @return string + */ + public function getSubtotal() + { + $subTotal = $this->_rootElement->find($this->subtotal, Locator::SELECTOR_CSS)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Subtotal text + * + * @return string + */ + public function getSubtotalExclTax() + { + $subTotal = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_CSS)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Subtotal text + * + * @return string + */ + public function getSubtotalInclTax() + { + $subTotal = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_CSS)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Shipping Excluding tax price text + * + * @return string|null + */ + public function getShippingInclTax() + { + $subTotal = $this->_rootElement->find($this->shippingInclTax, Locator::SELECTOR_CSS); + return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; + } + + /** + * Get Shipping Including tax price text + * + * @return string|null + */ + public function getShippingExclTax() + { + $subTotal = $this->_rootElement->find($this->shippingExclTax, Locator::SELECTOR_CSS); + return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; + } + + /** + * Method that escapes currency symbols + * + * @param string $price + * @return string|null + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreditMemoNew.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreditMemoNew.xml index 4dc2f4dec9a99..5091b94e8d137 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreditMemoNew.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreditMemoNew.xml @@ -16,5 +16,10 @@ #edit_form css selector + + Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Totals + .creditmemo-totals + css selector + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php new file mode 100644 index 0000000000000..aa48b9bf01cc0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php @@ -0,0 +1,206 @@ +orderView = $orderView; + $this->orderInvoiceNew = $orderInvoiceNew; + $this->orderCreditMemoNew = $orderCreditMemoNew; + $orderIndex->open(); + $orderIndex->getSalesOrderGrid()->openFirstRow(); + //Check prices on order page + $actualPrices = []; + $actualPrices = $this->getOrderPrices($actualPrices, $product); + $actualPrices = $this->getOrderTotals($actualPrices); + $prices = $this->preparePrices($prices); + $message = 'Prices on order view page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + $orderView->getPageActions()->invoice(); + //Check prices on invoice creation page + $actualPrices = []; + $actualPrices = $this->getInvoiceNewPrices($actualPrices, $product); + $actualPrices = $this->getInvoiceNewTotals($actualPrices); + $message = 'Prices on invoice new page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + $orderInvoiceNew->getTotalsBlock()->submit(); + //Check prices after invoice on order page + $actualPrices = []; + $actualPrices = $this->getOrderPrices($actualPrices, $product); + $actualPrices = $this->getOrderTotals($actualPrices); + $message = 'Prices on invoice page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + $orderView->getPageActions()->orderCreditMemo(); + //Check prices on credit memo creation page + $pricesCreditMemo = $this->preparePricesCreditMemo($prices); + $actualPrices = []; + $actualPrices = $this->getCreditMemoNewPrices($actualPrices, $product); + $actualPrices = $this->getCreditMemoNewTotals($actualPrices); + $message = 'Prices on credit memo new page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($pricesCreditMemo, $actualPrices, $message); + $orderCreditMemoNew->getFormBlock()->submit(); + //Check prices after refund on order page + $actualPrices = []; + $actualPrices = $this->getOrderPrices($actualPrices, $product); + $actualPrices = $this->getOrderTotals($actualPrices); + $message = 'Prices on credit memo page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + } + + /** + * Unset category and product page expected prices. + * + * @param array $prices + * @return array + */ + protected function preparePrices($prices) + { + if (isset($prices['category_price_excl_tax'])) { + unset($prices['category_price_excl_tax']); + } + if (isset($prices['category_price_incl_tax'])) { + unset($prices['category_price_incl_tax']); + } + if (isset($prices['product_view_price_excl_tax'])) { + unset($prices['product_view_price_excl_tax']); + } + if (isset($prices['product_view_price_incl_tax'])) { + unset($prices['product_view_price_incl_tax']); + } + return $prices; + } + + /** + * Unset category and product page expected prices. + * + * @param array $prices + * @return array + */ + protected function preparePricesCreditMemo($prices) + { + $prices['shipping_excl_tax'] = null; + $prices['shipping_incl_tax'] = null; + return $prices; + } + + /** + * Get order product prices. + * + * @param InjectableFixture $product + * @param $actualPrices + * @return array + */ + public function getOrderPrices($actualPrices, InjectableFixture $product) + { + $viewBlock = $this->orderView->getItemsOrderedBlock(); + $actualPrices['cart_item_price_excl_tax'] = $viewBlock->getItemPriceExclTax($product->getName()); + $actualPrices['cart_item_price_incl_tax'] = $viewBlock->getItemPriceInclTax($product->getName()); + $actualPrices['cart_item_subtotal_excl_tax'] = $viewBlock->getItemSubExclTax($product->getName()); + $actualPrices['cart_item_subtotal_incl_tax'] = $viewBlock->getItemSubInclTax($product->getName()); + return $actualPrices; + } + + /** + * Get invoice new product prices. + * + * @param InjectableFixture $product + * @param $actualPrices + * @return array + */ + public function getInvoiceNewPrices($actualPrices, InjectableFixture $product) + { + $productBlock = $this->orderInvoiceNew->getFormBlock()->getItemsBlock()->getItemProductBlock($product); + $actualPrices['cart_item_price_excl_tax'] = $productBlock->getItemPriceExclTax(); + $actualPrices['cart_item_price_incl_tax'] = $productBlock->getItemPriceInclTax(); + $actualPrices['cart_item_subtotal_excl_tax'] = $productBlock->getItemSubExclTax(); + $actualPrices['cart_item_subtotal_incl_tax'] = $productBlock->getItemSubInclTax(); + return $actualPrices; + } + + /** + * Get Credit Memo new product prices. + * + * @param InjectableFixture $product + * @param $actualPrices + * @return array + */ + public function getCreditMemoNewPrices($actualPrices, InjectableFixture $product) + { + $productBlock = $this->orderCreditMemoNew->getFormBlock()->getItemsBlock()->getItemProductBlock($product); + $actualPrices['cart_item_price_excl_tax'] = $productBlock->getItemPriceExclTax(); + $actualPrices['cart_item_price_incl_tax'] = $productBlock->getItemPriceInclTax(); + $actualPrices['cart_item_subtotal_excl_tax'] = $productBlock->getItemSubExclTax(); + $actualPrices['cart_item_subtotal_incl_tax'] = $productBlock->getItemSubInclTax(); + return $actualPrices; + } + + /** + * Text of price verification after order creation. + * + * @return string + */ + public function toString() + { + return 'Prices on backend after order creation is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php new file mode 100644 index 0000000000000..e83ccc155838b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php @@ -0,0 +1,157 @@ +checkoutOnepage = $checkoutOnepage; + $this->orderView = $orderView; + + $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout(); + $checkoutOnepage->getBillingBlock()->clickContinue(); + $shippingMethod = ['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed']; + $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shippingMethod); + $checkoutOnepage->getShippingMethodBlock()->clickContinue(); + $checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod(['method' => 'check_money_order']); + $checkoutOnepage->getPaymentMethodsBlock()->clickContinue(); + $actualPrices = []; + $actualPrices = $this->getReviewPrices($actualPrices, $product); + $actualPrices = $this->getReviewTotals($actualPrices); + $prices = $this->preparePrices($prices); + //Order review prices verification + $message = 'Prices on order review should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + + $checkoutOnepage->getReviewBlock()->placeOrder(); + $checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); + $checkoutOnepageSuccess->getSuccessBlock()->openOrder(); + $actualPrices = []; + $actualPrices = $this->getOrderPrices($actualPrices, $product); + $actualPrices = $this->getOrderTotals($actualPrices); + + //Frontend order prices verification + $message = 'Prices on order view page should be equal to defined in dataset.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); + } + + /** + * Prepare expected prices prices. + * + * @param array $prices + * @return array $prices + */ + protected function preparePrices($prices) + { + if (isset($prices['category_price_excl_tax'])) { + unset($prices['category_price_excl_tax']); + } + if (isset($prices['category_price_incl_tax'])) { + unset($prices['category_price_incl_tax']); + } + if (isset($prices['product_view_price_excl_tax'])) { + unset($prices['product_view_price_excl_tax']); + } + if (isset($prices['product_view_price_incl_tax'])) { + unset($prices['product_view_price_incl_tax']); + } + return $prices; + } + + /** + * Get review product prices. + * + * @param InjectableFixture $product + * @param $actualPrices + * @return array + */ + public function getReviewPrices($actualPrices, InjectableFixture $product) + { + $reviewBlock = $this->checkoutOnepage->getReviewBlock(); + $actualPrices['cart_item_price_excl_tax'] = $reviewBlock->getItemPriceExclTax($product->getName()); + $actualPrices['cart_item_price_incl_tax'] = $reviewBlock->getItemPriceInclTax($product->getName()); + $actualPrices['cart_item_subtotal_excl_tax'] = $reviewBlock->getItemSubExclTax($product->getName()); + $actualPrices['cart_item_subtotal_incl_tax'] = $reviewBlock->getItemSubInclTax($product->getName()); + return $actualPrices; + } + + /** + * Get order product prices. + * + * @param InjectableFixture $product + * @param $actualPrices + * @return array + */ + public function getOrderPrices($actualPrices, InjectableFixture $product) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['cart_item_price_excl_tax'] = $viewBlock->getItemPriceExclTax($product->getName()); + $actualPrices['cart_item_price_incl_tax'] = $viewBlock->getItemPriceInclTax($product->getName()); + $actualPrices['cart_item_subtotal_excl_tax'] = $viewBlock->getItemSubExclTax($product->getName()); + $actualPrices['cart_item_subtotal_incl_tax'] = $viewBlock->getItemSubInclTax($product->getName()); + return $actualPrices; + } + + /** + * Text of price verification after order creation + * + * @return string + */ + public function toString() + { + return 'Prices on front after order creation is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPrices.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php similarity index 54% rename from dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPrices.php rename to dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php index ac4a53f3f3131..6eb167d44c4c6 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPrices.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php @@ -5,58 +5,61 @@ namespace Magento\Tax\Test\Constraint; -use Magento\Catalog\Test\Fixture\CatalogProductSimple; +use Mtf\Constraint\AbstractConstraint; +use Magento\Cms\Test\Page\CmsIndex; use Magento\Catalog\Test\Page\Category\CatalogCategoryView; use Magento\Catalog\Test\Page\Product\CatalogProductView; use Magento\Checkout\Test\Page\CheckoutCart; -use Magento\Cms\Test\Page\CmsIndex; use Magento\Customer\Test\Fixture\AddressInjectable; -use Mtf\Constraint\AbstractConstraint; use Mtf\Fixture\FixtureFactory; +use Mtf\Fixture\InjectableFixture; /** - * Class AssertTaxRuleIsAppliedToAllPrice - * Checks that prices on category, product and cart pages are equal to specified in dataset + * Checks that prices excl tax on category, product and cart pages are equal to specified in dataset. */ -class AssertTaxRuleIsAppliedToAllPrices extends AbstractConstraint +abstract class AbstractAssertTaxRuleIsAppliedToAllPrices extends AbstractConstraint { - /* tags */ - const SEVERITY = 'high'; - /* end tags */ - /** - * Cms index page + * Cms index page. * * @var CmsIndex */ protected $cmsIndex; /** - * Catalog product page + * Catalog product page. * * @var catalogCategoryView */ protected $catalogCategoryView; /** - * Catalog product page + * Catalog product page. * * @var CatalogProductView */ protected $catalogProductView; /** - * Catalog product page + * Catalog product page. * * @var CheckoutCart */ protected $checkoutCart; /** - * Assert that specified prices are actual on category, product and cart pages + * Constraint severeness. * - * @param CatalogProductSimple $product + * @var string + */ + protected $severeness = 'high'; + + /** + * 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 @@ -65,8 +68,9 @@ class AssertTaxRuleIsAppliedToAllPrices extends AbstractConstraint * @return void */ public function processAssert( - CatalogProductSimple $product, + InjectableFixture $product, array $prices, + $qty, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductView $catalogProductView, @@ -80,98 +84,60 @@ public function processAssert( //Preconditions $address = $fixtureFactory->createByCode('addressInjectable', ['dataSet' => 'US_address_NY']); $shipping = ['carrier' => 'Flat Rate', 'method' => 'Fixed']; - + $actualPrices = []; //Assertion steps $productName = $product->getName(); - $this->openCategory($product); - $actualPrices = []; + $productCategory = $product->getCategoryIds()[0]; + $this->openCategory($productCategory); $actualPrices = $this->getCategoryPrices($productName, $actualPrices); $catalogCategoryView->getListProductBlock()->openProductViewPage($productName); + $catalogProductView->getViewBlock()->fillOptions($product); $actualPrices = $this->getProductPagePrices($actualPrices); - $catalogProductView->getViewBlock()->setQtyAndClickAddToCart(3); - $actualPrices = $this->getCartPrices($product, $actualPrices); + $catalogProductView->getViewBlock()->setQtyAndClickAddToCart($qty); $this->fillEstimateBlock($address, $shipping); + $actualPrices = $this->getCartPrices($product, $actualPrices); $actualPrices = $this->getTotals($actualPrices); - //Prices verification - \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, 'Arrays should be equal'); + $message = 'Prices from dataset should be equal to prices on frontend.'; + \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message); } /** - * Open product category + * Open product category. * - * @param CatalogProductSimple $product + * @param string $productCategory * @return void */ - public function openCategory(CatalogProductSimple $product) + public function openCategory($productCategory) { $this->cmsIndex->open(); - $this->cmsIndex->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]); + $this->cmsIndex->getTopmenu()->selectCategoryByName($productCategory); } - /** - * Get prices on category page - * - * @param $productName - * @param array $actualPrices - * @return array - */ - public function getCategoryPrices($productName, $actualPrices) - { - $actualPrices['category_price_excl_tax'] = - $this->catalogCategoryView - ->getListProductBlock() - ->getProductPriceBlock($productName) - ->getPriceExcludingTax(); - $actualPrices['category_price_incl_tax'] = - $this->catalogCategoryView - ->getListProductBlock() - ->getProductPriceBlock($productName) - ->getPriceIncludingTax(); - return $actualPrices; - } /** - * Get product view prices + * Get cart prices. * + * @param InjectableFixture $product * @param $actualPrices * @return array */ - public function getProductPagePrices($actualPrices) + public function getCartPrices(InjectableFixture $product, $actualPrices) { - $actualPrices['product_view_price_excl_tax'] = - $this->catalogProductView - ->getViewBlock() - ->getProductPriceExcludingTax(); - $actualPrices['product_view_price_incl_tax'] = - $this->catalogProductView - ->getViewBlock() - ->getProductPriceIncludingTax(); - return $actualPrices; - } - - /** - * Get cart prices - * - * @param CatalogProductSimple $product - * @param $actualPrices - * @return array - */ - public function getCartPrices(CatalogProductSimple $product, $actualPrices) - { - $actualPrices['cart_item_subtotal_excl_tax'] = - $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPrice(); - $actualPrices['cart_item_subtotal_incl_tax'] = - $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPriceInclTax(); $actualPrices['cart_item_price_excl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getPrice(); $actualPrices['cart_item_price_incl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getPriceInclTax(); + $actualPrices['cart_item_subtotal_excl_tax'] = + $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPrice(); + $actualPrices['cart_item_subtotal_incl_tax'] = + $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPriceInclTax(); + return $actualPrices; } /** - * Fill estimate block + * Fill estimate block. * * @param AddressInjectable $address * @param array $shipping @@ -183,27 +149,6 @@ public function fillEstimateBlock(AddressInjectable $address, $shipping) $this->checkoutCart->getShippingBlock()->selectShippingMethod($shipping); } - /** - * Get totals - * - * @param $actualPrices - * @return array - */ - public function getTotals($actualPrices) - { - $actualPrices['subtotal_excl_tax'] = $this->checkoutCart->getTotalsBlock()->getSubtotalExcludingTax(); - $actualPrices['subtotal_incl_tax'] = $this->checkoutCart->getTotalsBlock()->getSubtotalIncludingTax(); - $actualPrices['discount'] = $this->checkoutCart->getTotalsBlock()->getDiscount(); - $actualPrices['shipping_excl_tax'] = $this->checkoutCart->getTotalsBlock()->getShippingPrice(); - $actualPrices['shipping_incl_tax'] = $this->checkoutCart->getTotalsBlock()->getShippingPriceInclTax(); - $actualPrices['tax'] = $this->checkoutCart->getTotalsBlock()->getTax(); - $actualPrices['grand_total_excl_tax'] = - $this->checkoutCart->getTotalsBlock()->getGrandTotalExcludingTax(); - $actualPrices['grand_total_incl_tax'] = - $this->checkoutCart->getTotalsBlock()->getGrandTotalIncludingTax(); - return $actualPrices; - } - /** * Text of Tax Rule is applied * @@ -211,6 +156,6 @@ public function getTotals($actualPrices) */ public function toString() { - return 'Prices on front is correct'; + return 'Prices on front is correct.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php index 0dc49a4adda17..be4e4cf38d331 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxWithCrossBorderApplying.php @@ -166,7 +166,7 @@ protected function getCartPrice(CatalogProductSimple $product, $actualPrices) $actualPrices['cart_item_subtotal_incl_tax'] = $this->checkoutCart->getCartBlock()->getCartItem($product)->getSubtotalPriceInclTax(); $actualPrices['grand_total'] = - $this->checkoutCart->getTotalsBlock()->getGrandTotal(); + $this->checkoutCart->getTotalsBlock()->getGrandTotalIncludingTax(); return $actualPrices; } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php new file mode 100644 index 0000000000000..35c2ef2357283 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php @@ -0,0 +1,89 @@ +orderView->getOrderTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $viewBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $viewBlock->getSubtotalInclTax(); + + $actualPrices['discount'] = $viewBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $viewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get invoice new totals. + * + * @param $actualPrices + * @return array + */ + public function getInvoiceNewTotals($actualPrices) + { + $totalsBlock = $this->orderInvoiceNew->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotalInclTax(); + + $actualPrices['discount'] = $totalsBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get Credit Memo new totals. + * + * @param $actualPrices + * @return array + */ + public function getCreditMemoNewTotals($actualPrices) + { + $totalsBlock = $this->orderCreditMemoNew->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotalInclTax(); + + $actualPrices['discount'] = $totalsBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalInclTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingTax.php new file mode 100644 index 0000000000000..56a46a082f961 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingTax.php @@ -0,0 +1,91 @@ +orderView->getOrderTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $viewBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + + $actualPrices['discount'] = $viewBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + return $actualPrices; + } + + /** + * Get invoice new totals. + * + * @param $actualPrices + * @return array + */ + public function getInvoiceNewTotals($actualPrices) + { + $totalsBlock = $this->orderInvoiceNew->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + + $actualPrices['discount'] = $totalsBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get Credit Memo new totals. + * + * @param $actualPrices + * @return array + */ + public function getCreditMemoNewTotals($actualPrices) + { + $totalsBlock = $this->orderCreditMemoNew->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + + $actualPrices['discount'] = $totalsBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendIncludingTax.php new file mode 100644 index 0000000000000..71b228adcc3bf --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendIncludingTax.php @@ -0,0 +1,89 @@ +orderView->getOrderTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $viewBlock->getSubtotal(); + + $actualPrices['discount'] = $viewBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $viewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get invoice new totals. + * + * @param $actualPrices + * @return array + */ + public function getInvoiceNewTotals($actualPrices) + { + $totalsBlock = $this->orderInvoiceNew->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotal(); + + $actualPrices['discount'] = $totalsBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get Credit Memo new totals. + * + * @param $actualPrices + * @return array + */ + public function getCreditMemoNewTotals($actualPrices) + { + $totalsBlock = $this->orderCreditMemoNew->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotal(); + + $actualPrices['discount'] = $totalsBlock->getDiscount(); + + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalInclTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php new file mode 100644 index 0000000000000..29040ace5516d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php @@ -0,0 +1,62 @@ +checkoutOnepage->getReviewBlock(); + $actualPrices['subtotal_excl_tax'] = $reviewBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $reviewBlock->getSubtotalInclTax(); + $actualPrices['discount'] = $reviewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $reviewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $reviewBlock->getShippingInclTax(); + $actualPrices['tax'] = $reviewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $reviewBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $reviewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get order totals. + * + * @param $actualPrices + * @return array + */ + public function getOrderTotals($actualPrices) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['subtotal_excl_tax'] = $viewBlock->getSubtotalExclTax(); + $actualPrices['subtotal_incl_tax'] = $viewBlock->getSubtotalInclTax(); + $actualPrices['discount'] = $viewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = $viewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php new file mode 100644 index 0000000000000..dba356b8e4169 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php @@ -0,0 +1,63 @@ +checkoutOnepage->getReviewBlock(); + $actualPrices['subtotal_excl_tax'] = $reviewBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + $actualPrices['discount'] = $reviewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $reviewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $reviewBlock->getShippingInclTax(); + $actualPrices['tax'] = $reviewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $reviewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get order totals. + * + * @param $actualPrices + * @return array + */ + public function getOrderTotals($actualPrices) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['subtotal_excl_tax'] = $viewBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + + $actualPrices['discount'] = $viewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php new file mode 100644 index 0000000000000..89611a8946da4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php @@ -0,0 +1,62 @@ +checkoutOnepage->getReviewBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $reviewBlock->getSubtotal(); + $actualPrices['discount'] = $reviewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $reviewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $reviewBlock->getShippingInclTax(); + $actualPrices['tax'] = $reviewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $reviewBlock->getGrandTotalExclTax(); + $actualPrices['grand_total_incl_tax'] = $reviewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } + + /** + * Get order totals. + * + * @param $actualPrices + * @return array + */ + public function getOrderTotals($actualPrices) + { + $viewBlock = $this->orderView->getOrderViewBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $viewBlock->getSubtotal(); + $actualPrices['discount'] = $viewBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $viewBlock->getShippingExclTax(); + $actualPrices['shipping_incl_tax'] = $viewBlock->getShippingInclTax(); + $actualPrices['tax'] = $viewBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $viewBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = $viewBlock->getGrandTotalInclTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php new file mode 100644 index 0000000000000..a5badd6fd9031 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php @@ -0,0 +1,73 @@ +catalogCategoryView->getListProductBlock()->getProductPriceBlock($productName); + $actualPrices['category_price_excl_tax'] = $priceBlock->getPriceExcludingTax(); + $actualPrices['category_price_incl_tax'] = $priceBlock->getPriceIncludingTax(); + + return $actualPrices; + } + + /** + * Get product view prices. + * + * @param array $actualPrices + * @return array + */ + public function getProductPagePrices($actualPrices) + { + $viewBlock = $this->catalogProductView->getViewBlock(); + $actualPrices['product_view_price_excl_tax'] = $viewBlock->getProductPriceExcludingTax(); + $actualPrices['product_view_price_incl_tax'] = $viewBlock->getProductPriceIncludingTax(); + + return $actualPrices; + } + + /** + * Get totals. + * + * @param $actualPrices + * @return array + */ + public function getTotals($actualPrices) + { + $totalsBlock = $this->checkoutCart->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotalExcludingTax(); + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotalIncludingTax(); + $actualPrices['discount'] = $totalsBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingPrice(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingPriceInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotalExcludingTax(); + $actualPrices['grand_total_incl_tax'] = $totalsBlock->getGrandTotalIncludingTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingTax.php new file mode 100644 index 0000000000000..165d6cd23ac10 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingTax.php @@ -0,0 +1,73 @@ +catalogCategoryView->getListProductBlock()->getProductPriceBlock($productName); + $actualPrices['category_price_excl_tax'] = $priceBlock->getEffectivePrice(); + $actualPrices['category_price_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get product view prices. + * + * @param array $actualPrices + * @return array + */ + public function getProductPagePrices($actualPrices) + { + $viewBlock = $this->catalogProductView->getViewBlock(); + $actualPrices['product_view_price_excl_tax'] = $viewBlock->getPriceBlock()->getEffectivePrice(); + $actualPrices['product_view_price_incl_tax'] = null; + + return $actualPrices; + } + + /** + * Get totals. + * + * @param $actualPrices + * @return array + */ + public function getTotals($actualPrices) + { + $totalsBlock = $this->checkoutCart->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotal(); + $actualPrices['subtotal_incl_tax'] = null; + $actualPrices['discount'] = $totalsBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingPrice(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingPriceInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['grand_total_excl_tax'] = $totalsBlock->getGrandTotal(); + $actualPrices['grand_total_incl_tax'] = null; + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesIncludingTax.php new file mode 100644 index 0000000000000..ce12c61fbf1da --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesIncludingTax.php @@ -0,0 +1,73 @@ +catalogCategoryView->getListProductBlock()->getProductPriceBlock($productName); + $actualPrices['category_price_excl_tax'] = null; + $actualPrices['category_price_incl_tax'] = $priceBlock->getEffectivePrice(); + + return $actualPrices; + } + + /** + * Get product view prices. + * + * @param array $actualPrices + * @return array + */ + public function getProductPagePrices($actualPrices) + { + $viewBlock = $this->catalogProductView->getViewBlock(); + $actualPrices['product_view_price_excl_tax'] = null; + $actualPrices['product_view_price_incl_tax'] = $viewBlock->getPriceBlock()->getEffectivePrice(); + + return $actualPrices; + } + + /** + * Get totals. + * + * @param $actualPrices + * @return array + */ + public function getTotals($actualPrices) + { + $totalsBlock = $this->checkoutCart->getTotalsBlock(); + $actualPrices['subtotal_excl_tax'] = null; + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotal(); + $actualPrices['discount'] = $totalsBlock->getDiscount(); + $actualPrices['shipping_excl_tax'] = $totalsBlock->getShippingPrice(); + $actualPrices['shipping_incl_tax'] = $totalsBlock->getShippingPriceInclTax(); + $actualPrices['tax'] = $totalsBlock->getTax(); + $actualPrices['subtotal_excl_tax'] = $totalsBlock->getSubtotalExcludingTax(); + $actualPrices['subtotal_incl_tax'] = $totalsBlock->getSubtotalIncludingTax(); + + return $actualPrices; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php new file mode 100644 index 0000000000000..94bc1cd3b81ee --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php @@ -0,0 +1,65 @@ +fixtureFactory = $fixtureFactory; + $this->taxRule = $taxRule; + } + + /** + * Create tax rule + * + * @return array + */ + public function run() + { + $result['taxRule'] = null; + if ($this->taxRule != '-') { + $taxRule = $this->fixtureFactory->createByCode( + 'taxRule', + ['dataSet' => $this->taxRule] + ); + $taxRule->persist(); + $result['taxRule'] = $taxRule; + } + + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/etc/constraint.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/constraint.xml index f61aa496c071a..f44433948ca41 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/etc/constraint.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/constraint.xml @@ -56,6 +56,33 @@ high + + high + + + high + + + high + + + high + + + high + + + high + + + high + + + high + + + high + high diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml new file mode 100644 index 0000000000000..a1d4d406e4f07 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml @@ -0,0 +1,39 @@ + + + + + + + + setupConfiguration + + createSalesRule + + + createCatalogRule + + + createTaxRule + + + createProduct + + + createCustomer + + + loginCustomerOnFrontend + + + + + + + From 74ab06e72c0c58cca0a5fdb15fe087fa57cb0dfc Mon Sep 17 00:00:00 2001 From: Mike Weis Date: Mon, 5 Jan 2015 14:34:15 -0600 Subject: [PATCH 06/18] MAGETWO-28380: Totals taxes sorting is different on order/invoice/refund create and view pages - updated per code review --- app/code/Magento/Tax/Helper/Data.php | 18 +++++------------- .../testsuite/Magento/Tax/Helper/DataTest.php | 6 ++---- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/Tax/Helper/Data.php b/app/code/Magento/Tax/Helper/Data.php index a30fc64cc9608..f6660d68d44d7 100644 --- a/app/code/Magento/Tax/Helper/Data.php +++ b/app/code/Magento/Tax/Helper/Data.php @@ -682,23 +682,17 @@ public function getCalculatedTaxes($source) * 'tax_amount' => $taxAmount, * 'base_tax_amount' => $baseTaxAmount, * 'title' => $title, - * 'percent' => $percent, - * 'type' => $type + * 'percent' => $percent * ) * ) * * @param array $taxClassAmount * @param OrderTaxDetailsItemInterface $itemTaxDetail * @param float $ratio - * @param string $type * @return array */ - private function _aggregateTaxes( - $taxClassAmount, - OrderTaxDetailsItemInterface $itemTaxDetail, - $ratio, - $type = 'product' - ) { + private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $itemTaxDetail, $ratio) + { $itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes(); foreach ($itemAppliedTaxes as $itemAppliedTax) { $taxAmount = $itemAppliedTax->getAmount() * $ratio; @@ -711,7 +705,6 @@ private function _aggregateTaxes( if (!isset($taxClassAmount[$taxCode])) { $taxClassAmount[$taxCode]['title'] = $itemAppliedTax->getTitle(); $taxClassAmount[$taxCode]['percent'] = $itemAppliedTax->getPercent(); - $taxClassAmount[$taxCode]['type'] = $type; $taxClassAmount[$taxCode]['tax_amount'] = $taxAmount; $taxClassAmount[$taxCode]['base_tax_amount'] = $baseTaxAmount; } else { @@ -835,7 +828,6 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface } // Apply any taxes for shipping - $shippingType = \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING; $shippingTaxAmount = $salesItem->getShippingTaxAmount(); $originalShippingTaxAmount = $order->getShippingTaxAmount(); if ($shippingTaxAmount && $originalShippingTaxAmount && @@ -846,9 +838,9 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface $itemTaxDetails = $orderTaxDetails->getItems(); foreach ($itemTaxDetails as $itemTaxDetail) { //Aggregate taxable items associated with shipping - if ($itemTaxDetail->getType() == $shippingType) { + if ($itemTaxDetail->getType() == \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING) { $taxClassAmount = - $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio, $shippingType); + $this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio); } } } diff --git a/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php index 6b01c6385e2eb..aabfe565bb706 100644 --- a/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php @@ -301,7 +301,6 @@ public function getCalculatedTaxesForOrderItemsDataProvider() 'percent' => 20.0, 'tax_amount' => 2.5, 'base_tax_amount' => 2.5, - 'type' => 'product', ], ], ], @@ -363,11 +362,11 @@ public function getCalculatedTaxesForOrderItemsDataProvider() 'percent' => 20.0, 'tax_amount' => 6.5, 'base_tax_amount' => 6.5, - 'type' => 'product', ], ], ], //Scenario 3: one item, with both shipping and product taxes + // note that 'shipping tax' is listed before 'product tax' 'one_item_with_both_shipping_and_product_taxes' => [ 'order' => [ 'order_id' => 1, @@ -418,20 +417,19 @@ public function getCalculatedTaxesForOrderItemsDataProvider() ), ], ], + // note that 'shipping tax' is now listed after 'product tax' 'expected_results' => [ [ 'title' => 'US-CA-Sales-Tax', 'percent' => 20.0, 'tax_amount' => 5.00, 'base_tax_amount' => 5.00, - 'type' => 'product', ], [ 'title' => 'US-CA-Sales-Tax-Ship', 'percent' => 10.0, 'tax_amount' => 2.00, 'base_tax_amount' => 2.00, - 'type' => 'shipping', ], ], ], From efdfa434c1cc01fb412924fdddee63d861a14dca Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Tue, 6 Jan 2015 11:43:03 +0200 Subject: [PATCH 07/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - CR fixes --- ...axCalculationAfterCheckoutDownloadable.php | 2 +- ...axRuleIsAppliedToAllPricesDownloadable.php | 2 +- ...iedToAllPricesDownloadableExcludingTax.php | 2 +- ...iedToAllPricesDownloadableIncludingTax.php | 2 +- .../GroupPriceOptions.php | 11 +- .../DownloadableTaxCalculationTest.php | 2 +- .../DownloadableTaxCalculationTest/test.csv | 16 +- .../Adminhtml/Order/AbstractForm/Totals.php | 210 ------------------ .../Block/Adminhtml/Order/Invoice/Totals.php | 2 +- .../Test/Block/Adminhtml/Order/Totals.php | 204 ++++++++++++++++- .../AbstractAssertOrderTaxOnBackend.php | 54 +++-- ...tractAssertTaxCalculationAfterCheckout.php | 16 ++ ...tractAssertTaxRuleIsAppliedToAllPrices.php | 25 +++ ...OrderTaxOnBackendExcludingIncludingTax.php | 6 +- 14 files changed, 294 insertions(+), 260 deletions(-) delete mode 100644 dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm/Totals.php diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php index 7bc83be16a65f..290600821dfb5 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php @@ -16,7 +16,7 @@ /** * Checks that prices excl tax on order review and customer order pages are equal to specified in dataset. */ -class AbstractAssertTaxCalculationAfterCheckoutDownloadable extends AbstractAssertTaxCalculationAfterCheckout +abstract class AbstractAssertTaxCalculationAfterCheckoutDownloadable extends AbstractAssertTaxCalculationAfterCheckout { /** * Constraint severeness diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php index 6075d98c4c5a5..35da65f95f235 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php @@ -16,7 +16,7 @@ /** * Checks that product prices excl tax on category, product and cart pages are equal to specified in dataset. */ -class AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable extends AbstractAssertTaxRuleIsAppliedToAllPrices +abstract class AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable extends AbstractAssertTaxRuleIsAppliedToAllPrices { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php index d22ef9970238a..8845f2545964d 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php @@ -53,7 +53,7 @@ public function getProductPagePrices($actualPrices) /** * Get totals. * - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getTotals($actualPrices) diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php index 3c8240990191f..2ce8b695acb43 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php @@ -21,7 +21,7 @@ class AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax /** * Get prices on category page. * - * @param $productName + * @param string $productName * @param array $actualPrices * @return array */ diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php index 14a1482d9390b..ef1024f4013b3 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php @@ -1,19 +1,12 @@ _rootElement->find($this->grandTotal, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($grandTotal); - } - - /** - * Get Grand Total Excluding Tax Text - * - * @return string - */ - public function getGrandTotalExclTax() - { - $grandTotal = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($grandTotal); - } - - /** - * Get Grand Total Including Tax Text - * - * @return string - */ - public function getGrandTotalInclTax() - { - $grandTotal = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($grandTotal); - } - - /** - * Get Tax text from Order Totals - * - * @return string - */ - public function getTax() - { - $tax = $this->_rootElement->find($this->tax, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($tax); - } - - /** - * Get Tax text from Order Totals - * - * @return string|null - */ - public function getDiscount() - { - $discount = $this->_rootElement->find($this->discount, Locator::SELECTOR_XPATH); - return $discount->isVisible() ? $this->escapeCurrency($discount->getText()) : null; - } - - /** - * Get Subtotal text - * - * @return string - */ - public function getSubtotal() - { - $subTotal = $this->_rootElement->find($this->subtotal, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($subTotal); - } - - /** - * Get Subtotal text - * - * @return string - */ - public function getSubtotalExclTax() - { - $subTotal = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($subTotal); - } - - /** - * Get Subtotal text - * - * @return string - */ - public function getSubtotalInclTax() - { - $subTotal = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_XPATH)->getText(); - return $this->escapeCurrency($subTotal); - } - - /** - * Get Shipping Excluding tax price text - * - * @return string|null - */ - public function getShippingInclTax() - { - $subTotal = $this->_rootElement->find($this->shippingInclTax, Locator::SELECTOR_XPATH); - return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; - } - - /** - * Get Shipping Including tax price text - * - * @return string|null - */ - public function getShippingExclTax() - { - $subTotal = $this->_rootElement->find($this->shippingExclTax, Locator::SELECTOR_XPATH); - return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; - } - - /** - * Method that escapes currency symbols - * - * @param string $price - * @return string|null - */ - protected function escapeCurrency($price) - { - preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); - return (isset($matches[1])) ? $matches[1] : null; - } -} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php index 819c75229fa79..158a0f9abc0c3 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Totals.php @@ -11,7 +11,7 @@ * Class Totals * Invoice totals block */ -class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Totals +class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\Totals { /** * Submit invoice button selector diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php index 88b5b445d3ff3..98d5718ae0f17 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php @@ -1,14 +1,210 @@ _rootElement->find($this->grandTotal, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Grand Total Excluding Tax Text. + * + * @return string + */ + public function getGrandTotalExclTax() + { + $grandTotal = $this->_rootElement->find($this->grandTotalExclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Grand Total Including Tax Text. + * + * @return string + */ + public function getGrandTotalInclTax() + { + $grandTotal = $this->_rootElement->find($this->grandTotalInclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($grandTotal); + } + + /** + * Get Tax text from Order Totals. + * + * @return string + */ + public function getTax() + { + $tax = $this->_rootElement->find($this->tax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($tax); + } + + /** + * Get Tax text from Order Totals. + * + * @return string|null + */ + public function getDiscount() + { + $discount = $this->_rootElement->find($this->discount, Locator::SELECTOR_XPATH); + return $discount->isVisible() ? $this->escapeCurrency($discount->getText()) : null; + } + + /** + * Get Subtotal text. + * + * @return string + */ + public function getSubtotal() + { + $subTotal = $this->_rootElement->find($this->subtotal, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Subtotal text. + * + * @return string + */ + public function getSubtotalExclTax() + { + $subTotal = $this->_rootElement->find($this->subtotalExclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Subtotal text. + * + * @return string + */ + public function getSubtotalInclTax() + { + $subTotal = $this->_rootElement->find($this->subtotalInclTax, Locator::SELECTOR_XPATH)->getText(); + return $this->escapeCurrency($subTotal); + } + + /** + * Get Shipping Excluding tax price text. + * + * @return string|null + */ + public function getShippingInclTax() + { + $subTotal = $this->_rootElement->find($this->shippingInclTax, Locator::SELECTOR_XPATH); + return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; + } + + /** + * Get Shipping Including tax price text. + * + * @return string|null + */ + public function getShippingExclTax() + { + $subTotal = $this->_rootElement->find($this->shippingExclTax, Locator::SELECTOR_XPATH); + return $subTotal->isVisible() ? $this->escapeCurrency($subTotal->getText()) : null; + } + + /** + * Method that escapes currency symbols. + * + * @param string $price + * @return string|null + */ + protected function escapeCurrency($price) + { + preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches); + return (isset($matches[1])) ? $matches[1] : null; + } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php index aa48b9bf01cc0..b7c817909489d 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php @@ -45,12 +45,36 @@ abstract class AbstractAssertOrderTaxOnBackend extends AbstractConstraint */ protected $severeness = 'high'; + /** + * Implementation assert + * + * @param array $actualPrices + * @return array + */ + abstract protected function getOrderTotals($actualPrices); + + /** + * Implementation assert + * + * @param array $actualPrices + * @return array + */ + abstract protected function getInvoiceNewTotals($actualPrices); + + /** + * Implementation getCreditMemoNewTotals + * + * @param array $actualPrices + * @return array + */ + abstract protected function getCreditMemoNewTotals($actualPrices); + /** * Assert that specified prices are actual on order, invoice and refund pages. * * @param array $prices * @param InjectableFixture $product - * @param OrderIndex $orderIndex , + * @param OrderIndex $orderIndex * @param OrderView $orderView * @param OrderInvoiceNew $orderInvoiceNew * @param OrderCreditMemoNew $orderCreditMemoNew @@ -115,18 +139,18 @@ public function processAssert( */ protected function preparePrices($prices) { - if (isset($prices['category_price_excl_tax'])) { - unset($prices['category_price_excl_tax']); - } - if (isset($prices['category_price_incl_tax'])) { - unset($prices['category_price_incl_tax']); - } - if (isset($prices['product_view_price_excl_tax'])) { - unset($prices['product_view_price_excl_tax']); - } - if (isset($prices['product_view_price_incl_tax'])) { - unset($prices['product_view_price_incl_tax']); + $deletePrices = [ + 'category_price_excl_tax', + 'category_price_incl_tax', + 'product_view_price_excl_tax', + 'product_view_price_incl_tax' + ]; + foreach ($deletePrices as $key) { + if (array_key_exists($key, $prices)) { + unset($prices[$key]); + } } + return $prices; } @@ -147,7 +171,7 @@ protected function preparePricesCreditMemo($prices) * Get order product prices. * * @param InjectableFixture $product - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getOrderPrices($actualPrices, InjectableFixture $product) @@ -164,7 +188,7 @@ public function getOrderPrices($actualPrices, InjectableFixture $product) * Get invoice new product prices. * * @param InjectableFixture $product - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getInvoiceNewPrices($actualPrices, InjectableFixture $product) @@ -181,7 +205,7 @@ public function getInvoiceNewPrices($actualPrices, InjectableFixture $product) * Get Credit Memo new product prices. * * @param InjectableFixture $product - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getCreditMemoNewPrices($actualPrices, InjectableFixture $product) diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php index e83ccc155838b..51c7b44bf0b04 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxCalculationAfterCheckout.php @@ -39,6 +39,22 @@ abstract class AbstractAssertTaxCalculationAfterCheckout extends AbstractConstra */ protected $severeness = 'high'; + /** + * Implementation getReviewTotals + * + * @param array $actualPrices + * @return array + */ + abstract protected function getReviewTotals($actualPrices); + + /** + * Implementation getOrderTotals + * + * @param array $actualPrices + * @return array + */ + abstract protected function getOrderTotals($actualPrices); + /** * Assert that prices on order review and customer order pages are equal to specified in dataset. * diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php index 6eb167d44c4c6..52cb287f119a3 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertTaxRuleIsAppliedToAllPrices.php @@ -54,6 +54,31 @@ abstract class AbstractAssertTaxRuleIsAppliedToAllPrices extends AbstractConstra */ protected $severeness = 'high'; + /** + * Implementation getCategoryPrices + * + * @param string $productName + * @param array $actualPrices + * @return array + */ + abstract protected function getCategoryPrices($productName, $actualPrices); + + /** + * Implementation getProductPagePrices + * + * @param array $actualPrices + * @return array + */ + abstract protected function getProductPagePrices($actualPrices); + + /** + * Implementation getTotals + * + * @param array $actualPrices + * @return array + */ + abstract protected function getTotals($actualPrices); + /** * Assert that specified prices are actual on category, product and cart pages. * diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php index 35c2ef2357283..66ecdadac13fe 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertOrderTaxOnBackendExcludingIncludingTax.php @@ -20,7 +20,7 @@ class AssertOrderTaxOnBackendExcludingIncludingTax extends AbstractAssertOrderTa /** * Get order totals. * - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getOrderTotals($actualPrices) @@ -43,7 +43,7 @@ public function getOrderTotals($actualPrices) /** * Get invoice new totals. * - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getInvoiceNewTotals($actualPrices) @@ -67,7 +67,7 @@ public function getInvoiceNewTotals($actualPrices) /** * Get Credit Memo new totals. * - * @param $actualPrices + * @param array $actualPrices * @return array */ public function getCreditMemoNewTotals($actualPrices) From b1ceba97200d97a94d21e43e7c479136cd623019 Mon Sep 17 00:00:00 2001 From: Yu Tang Date: Tue, 6 Jan 2015 15:51:44 -0600 Subject: [PATCH 08/18] MAGETWO-32364: Improve performance in pricing framework --- app/code/Magento/Catalog/Model/Product.php | 6 ++++-- .../Magento/Catalog/Model/ProductTest.php | 8 ++++++- .../Pricing/Price/CollectionTest.php | 2 ++ .../Framework/Pricing/Price/Collection.php | 21 ++++++++++++++----- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index b26ffe5bdcf7c..f23e7167cb583 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -776,8 +776,10 @@ public function afterSave() */ public function setQty($qty) { - $this->setData('qty', $qty); - $this->reloadPriceInfo(); + if ($this->getData('qty') != $qty) { + $this->setData('qty', $qty); + $this->reloadPriceInfo(); + } return $this; } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php index c94f539159a72..82d7278fc0e34 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php @@ -423,10 +423,16 @@ public function testGetPriceInfo() */ public function testSetQty() { - $this->productTypeInstanceMock->expects($this->once()) + $this->productTypeInstanceMock->expects($this->exactly(2)) ->method('getPriceInfo') ->with($this->equalTo($this->model)) ->will($this->returnValue($this->_priceInfoMock)); + + //initialize the priceInfo field + $this->model->getPriceInfo(); + //Calling setQty will reset the priceInfo field + $this->assertEquals($this->model, $this->model->setQty(1)); + //Call the setQty method with the same qty, getPriceInfo should not be called this time $this->assertEquals($this->model, $this->model->setQty(1)); $this->assertEquals($this->model->getPriceInfo(), $this->_priceInfoMock); } diff --git a/dev/tests/unit/testsuite/Magento/Framework/Pricing/Price/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Framework/Pricing/Price/CollectionTest.php index 518d0e8be36fc..eaf3fb43e9000 100644 --- a/dev/tests/unit/testsuite/Magento/Framework/Pricing/Price/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Framework/Pricing/Price/CollectionTest.php @@ -79,6 +79,8 @@ public function testGet() ) ->will($this->returnValue($this->priceMock)); $this->assertEquals($this->priceMock, $this->collection->get('regular_price')); + //Calling the get method again with the same code, cached copy should be used + $this->assertEquals($this->priceMock, $this->collection->get('regular_price')); } /** diff --git a/lib/internal/Magento/Framework/Pricing/Price/Collection.php b/lib/internal/Magento/Framework/Pricing/Price/Collection.php index ed5fc69fac38b..b18fc76bb9e59 100644 --- a/lib/internal/Magento/Framework/Pricing/Price/Collection.php +++ b/lib/internal/Magento/Framework/Pricing/Price/Collection.php @@ -42,6 +42,13 @@ class Collection implements \Iterator */ protected $excludes; + /** + * Cached price models + * + * @var array + */ + protected $priceModels; + /** * Constructor * @@ -60,6 +67,7 @@ public function __construct( $this->priceFactory = $priceFactory; $this->pool = $pool; $this->quantity = $quantity; + $this->priceModels = []; } /** @@ -120,10 +128,13 @@ public function valid() */ public function get($code) { - return $this->priceFactory->create( - $this->saleableItem, - $this->pool[$code], - $this->quantity - ); + if (!isset($this->priceModels[$code])) { + $this->priceModels[$code] = $this->priceFactory->create( + $this->saleableItem, + $this->pool[$code], + $this->quantity + ); + } + return $this->priceModels[$code]; } } From cc5a21566d26ae4ceecfbf01a7cbc344bb44dc17 Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Fri, 9 Jan 2015 16:30:08 +0200 Subject: [PATCH 09/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - Downloadable goup price fix and tax bug skip MAGETWO-18521 --- .../DownloadableProductInjectable/GroupPriceOptions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php index ef1024f4013b3..374f9be0460fb 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProductInjectable/GroupPriceOptions.php @@ -19,6 +19,13 @@ class GroupPriceOptions extends \Magento\Catalog\Test\Fixture\CatalogProductSimp protected function getPreset($name) { $presets = [ + 'default' => [ + [ + 'price' => 20, + 'website' => 'All Websites [USD]', + 'customer_group' => 'NOT LOGGED IN', + ], + ], 'downloadable_with_tax' => [ [ 'price' => 20.00, From 819015cc492b8e943cf05bb776d132a3b41e399b Mon Sep 17 00:00:00 2001 From: Yu Tang Date: Fri, 9 Jan 2015 09:40:24 -0600 Subject: [PATCH 10/18] MAGETWO-30415: [GITHUB] \Magento\Framework\Pricing\PriceCurrencyInterface depends on Magento application code #682 --- app/code/Magento/Directory/Model/PriceCurrency.php | 8 +------- .../Magento/Framework/Pricing/PriceCurrencyInterface.php | 6 +++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Directory/Model/PriceCurrency.php b/app/code/Magento/Directory/Model/PriceCurrency.php index 3cc16e54ca6e2..77e8410eb02e0 100644 --- a/app/code/Magento/Directory/Model/PriceCurrency.php +++ b/app/code/Magento/Directory/Model/PriceCurrency.php @@ -57,13 +57,7 @@ public function convert($amount, $scope = null, $currency = null) } /** - * Convert and round price value for specified store or passed currency - * - * @param float $amount - * @param null|string|bool|int|\Magento\Store\Model\Store $store - * @param Currency|string|null $currency - * @param int $precision - * @return float + * {@inheritdoc} */ public function convertAndRound($amount, $store = null, $currency = null, $precision = self::DEFAULT_PRECISION) { diff --git a/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php b/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php index a1ec1dde8cfec..1347dd006c255 100644 --- a/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php +++ b/lib/internal/Magento/Framework/Pricing/PriceCurrencyInterface.php @@ -29,12 +29,12 @@ public function convert($amount, $scope = null, $currency = null); * Convert and round price value * * @param float $amount - * @param null|string|bool|int|\Magento\Store\Model\Store $store - * @param \Magento\Directory\Model\Currency|string|null $currency + * @param null|string|bool|int|\Magento\Framework\App\ScopeInterface $scope + * @param \Magento\Framework\Model\AbstractModel|string|null $currency * @param int $precision * @return float */ - public function convertAndRound($amount, $store = null, $currency = null, $precision = self::DEFAULT_PRECISION); + public function convertAndRound($amount, $scope = null, $currency = null, $precision = self::DEFAULT_PRECISION); /** * Format price value From b7cde0221cb8a7ccd49775c94433249e5f2d1d4d Mon Sep 17 00:00:00 2001 From: Yu Tang Date: Fri, 9 Jan 2015 15:10:37 -0600 Subject: [PATCH 11/18] MAGETWO-30415: [GITHUB] \Magento\Framework\Pricing\PriceCurrencyInterface depends on Magento application code #682 - Change parameter name in implementation class to be consistent with interface --- app/code/Magento/Directory/Model/PriceCurrency.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Directory/Model/PriceCurrency.php b/app/code/Magento/Directory/Model/PriceCurrency.php index 77e8410eb02e0..e30e2059b39c2 100644 --- a/app/code/Magento/Directory/Model/PriceCurrency.php +++ b/app/code/Magento/Directory/Model/PriceCurrency.php @@ -59,10 +59,10 @@ public function convert($amount, $scope = null, $currency = null) /** * {@inheritdoc} */ - public function convertAndRound($amount, $store = null, $currency = null, $precision = self::DEFAULT_PRECISION) + public function convertAndRound($amount, $scope = null, $currency = null, $precision = self::DEFAULT_PRECISION) { - $currentCurrency = $this->getCurrency($store, $currency); - $convertedValue = $this->getStore($store)->getBaseCurrency()->convert($amount, $currentCurrency); + $currentCurrency = $this->getCurrency($scope, $currency); + $convertedValue = $this->getStore($scope)->getBaseCurrency()->convert($amount, $currentCurrency); return round($convertedValue, $precision); } From ddd3d6976cf3f018cd960db35e5ef659f265a1e9 Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Mon, 12 Jan 2015 11:14:54 +0200 Subject: [PATCH 12/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - CR fixes --- .../app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php | 5 +---- .../Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php | 6 +++--- .../AbstractAssertTaxCalculationAfterCheckout.php | 4 ++-- .../AbstractAssertTaxRuleIsAppliedToAllPrices.php | 6 +++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php index 98d5718ae0f17..a5ebf67d3711f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Totals.php @@ -1,9 +1,6 @@ Date: Wed, 14 Jan 2015 18:27:57 +0200 Subject: [PATCH 13/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - Fixed copyrights in merged files --- .../AbstractAssertTaxCalculationAfterCheckoutDownloadable.php | 3 ++- .../AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable.php | 3 ++- ...culationAfterCheckoutDownloadableExcludingIncludingTax.php | 3 ++- ...ertTaxCalculationAfterCheckoutDownloadableExcludingTax.php | 3 ++- ...ertTaxCalculationAfterCheckoutDownloadableIncludingTax.php | 3 ++- ...eIsAppliedToAllPricesDownloadableExcludingIncludingTax.php | 3 ++- ...ertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php | 3 ++- ...ertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php | 3 ++- .../DownloadableProductInjectable/GroupPriceOptions.php | 3 ++- .../Test/TestCase/DownloadableTaxCalculationTest.php | 3 ++- .../tests/app/Magento/Downloadable/Test/etc/scenario.xml | 3 ++- .../Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php | 3 ++- .../Constraint/AbstractAssertTaxCalculationAfterCheckout.php | 3 ++- .../AssertOrderTaxOnBackendExcludingIncludingTax.php | 3 ++- .../Test/Constraint/AssertOrderTaxOnBackendExcludingTax.php | 3 ++- .../Test/Constraint/AssertOrderTaxOnBackendIncludingTax.php | 3 ++- ...AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php | 3 ++- .../AssertTaxCalculationAfterCheckoutExcludingTax.php | 4 ++-- .../AssertTaxCalculationAfterCheckoutIncludingTax.php | 3 ++- ...AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php | 3 ++- .../AssertTaxRuleIsAppliedToAllPricesExcludingTax.php | 3 ++- .../AssertTaxRuleIsAppliedToAllPricesIncludingTax.php | 3 ++- 22 files changed, 44 insertions(+), 23 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php index 290600821dfb5..f8bf3012cfa96 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AbstractAssertTaxCalculationAfterCheckoutDownloadable.php @@ -1,6 +1,7 @@ diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php index 982a52c8bffe0..aa63949e9de9d 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AbstractAssertOrderTaxOnBackend.php @@ -1,6 +1,7 @@ Date: Wed, 14 Jan 2015 13:54:58 -0600 Subject: [PATCH 14/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - updated copyright statements --- .../CatalogRule/Test/TestStep/CreateCatalogRuleStep.php | 6 ++---- .../app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php | 6 ++---- .../functional/tests/app/Magento/Tax/Test/etc/scenario.xml | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php index f0c087db7ab05..f17c6b3962160 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php @@ -1,9 +1,7 @@ From d6599759b00d95885585118e0810b4a290012756 Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Thu, 15 Jan 2015 11:25:19 +0200 Subject: [PATCH 15/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - Fixes for L3 fails --- ...ulationAfterCheckoutDownloadableExcludingIncludingTax.php | 4 ++-- ...rtTaxCalculationAfterCheckoutDownloadableExcludingTax.php | 4 ++-- ...rtTaxCalculationAfterCheckoutDownloadableIncludingTax.php | 4 ++-- ...IsAppliedToAllPricesDownloadableExcludingIncludingTax.php | 4 ++-- ...rtTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php | 4 ++-- ...rtTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php | 4 ++-- .../Test/Repository/DownloadableProductInjectable.php | 1 + .../tests/app/Magento/Sales/Test/Block/Order/View.php | 2 ++ ...ssertTaxCalculationAfterCheckoutExcludingIncludingTax.php | 4 ++-- .../AssertTaxCalculationAfterCheckoutExcludingTax.php | 3 +-- .../AssertTaxCalculationAfterCheckoutIncludingTax.php | 3 +-- ...ssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php | 5 +++-- 12 files changed, 22 insertions(+), 20 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php index 1132a5eba4d19..64896843ae68b 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax.php @@ -9,8 +9,8 @@ /** * Checks that prices excl and incl tax on order review and customer order pages are equal to specified in dataset. */ -class AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax - extends AbstractAssertTaxCalculationAfterCheckoutDownloadable +class AssertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax extends + AbstractAssertTaxCalculationAfterCheckoutDownloadable { /** * Constraint severeness diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php index f267489372819..60a4e36293d08 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableExcludingTax.php @@ -11,8 +11,8 @@ /** * Checks that prices excl tax on order review and customer order pages are equal to specified in dataset. */ -class AssertTaxCalculationAfterCheckoutDownloadableExcludingTax - extends AbstractAssertTaxCalculationAfterCheckoutDownloadable +class AssertTaxCalculationAfterCheckoutDownloadableExcludingTax extends + AbstractAssertTaxCalculationAfterCheckoutDownloadable { /** * Constraint severeness diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php index 88ee73b5067cd..653b30217dbb1 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxCalculationAfterCheckoutDownloadableIncludingTax.php @@ -9,8 +9,8 @@ /** * Checks that prices incl tax on order review and customer order pages are equal to specified in dataset. */ -class AssertTaxCalculationAfterCheckoutDownloadableIncludingTax - extends AbstractAssertTaxCalculationAfterCheckoutDownloadable +class AssertTaxCalculationAfterCheckoutDownloadableIncludingTax extends + AbstractAssertTaxCalculationAfterCheckoutDownloadable { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php index a19281b101d3e..2ea9f0bc5bd24 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax.php @@ -9,8 +9,8 @@ /** * Checks that prices excl tax on category, product and cart pages are equal to specified in dataset. */ -class AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax - extends AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable +class AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax extends + AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php index a48b94174bcb7..eaa5d5e115f59 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax.php @@ -9,8 +9,8 @@ /** * Checks that product prices excl tax on category, product and cart pages are equal to specified in dataset. */ -class AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax - extends AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable +class AssertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax extends + AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php index 61a282eda0392..31fc3a1154b3d 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax.php @@ -9,8 +9,8 @@ /** * Checks that prices incl tax on category, product and cart pages are equal to specified in dataset. */ -class AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax - extends AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable +class AssertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax extends + AbstractAssertTaxRuleIsAppliedToAllPricesDownloadable { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php index 156d1c2348c24..240e3b2b1b206 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Repository/DownloadableProductInjectable.php @@ -21,6 +21,7 @@ class DownloadableProductInjectable extends AbstractRepository * @param array $defaultData [optional] * * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function __construct(array $defaultConfig = [], array $defaultData = []) { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php index f318d074c46dd..8e732491a4495 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Order/View.php @@ -12,6 +12,8 @@ /** * Class View * View block on order's view page + * + * @SuppressWarnings(PHPMD.TooManyFields) */ class View extends Block { diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php index e4219643ae8f6..7d65c80e0aee4 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingIncludingTax.php @@ -9,8 +9,8 @@ /** * Checks that prices excl and incl tax on order review and customer order pages are equal to specified in dataset. */ -class AssertTaxCalculationAfterCheckoutExcludingIncludingTax - extends AbstractAssertTaxCalculationAfterCheckout +class AssertTaxCalculationAfterCheckoutExcludingIncludingTax extends + AbstractAssertTaxCalculationAfterCheckout { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php index e925881d8adb5..eecf9cc8c8740 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutExcludingTax.php @@ -8,8 +8,7 @@ /** * Checks that prices including tax on order review and customer order pages are equal to specified in dataset. */ -class AssertTaxCalculationAfterCheckoutExcludingTax extends - AbstractAssertTaxCalculationAfterCheckout +class AssertTaxCalculationAfterCheckoutExcludingTax extends AbstractAssertTaxCalculationAfterCheckout { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php index e7079263b0e9f..59869e99eaa92 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxCalculationAfterCheckoutIncludingTax.php @@ -9,8 +9,7 @@ /** * Checks that prices including tax on order review and customer order pages are equal to specified in dataset. */ -class AssertTaxCalculationAfterCheckoutIncludingTax extends - AbstractAssertTaxCalculationAfterCheckout +class AssertTaxCalculationAfterCheckoutIncludingTax extends AbstractAssertTaxCalculationAfterCheckout { /** * Constraint severeness. diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php index 55ea81d13ced4..b685b18e9608d 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax.php @@ -7,11 +7,12 @@ namespace Magento\Tax\Test\Constraint; use Magento\Catalog\Test\Fixture\CatalogProductSimple; + /** * Checks that prices excl and incl tax on category, product and cart pages are equal to specified in dataset */ -class AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax - extends AbstractAssertTaxRuleIsAppliedToAllPrices +class AssertTaxRuleIsAppliedToAllPricesExcludingIncludingTax extends + AbstractAssertTaxRuleIsAppliedToAllPrices { /** * Constraint severeness. From fd63128fdb02a1b0993371e758fdc6e74bcae278 Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Tue, 20 Jan 2015 11:51:59 +0200 Subject: [PATCH 16/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - Fixes for L1 fails --- .../DownloadableTaxCalculationTest.php | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php index 82b90a1bbecd8..c810efd779521 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php @@ -6,7 +6,7 @@ namespace Magento\Downloadable\Test\TestCase; -use Magento\Tax\Test\TestCase\TaxCalculationTest; +use Mtf\TestCase\Scenario; /** * Test tax calculation with downloadable product. @@ -30,7 +30,43 @@ * @group Tax_(CS) * @ZephyrId MAGETWO-32076 */ -class DownloadableTaxCalculationTest extends TaxCalculationTest +class DownloadableTaxCalculationTest extends Scenario { - // + /** + * Skip failed tests. + * + * @return void + */ + public static function setUpBeforeClass() + { + self::markTestIncomplete("Epic: MAGETWO-30073"); + } + + /** + * Runs tax calculation test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } + + /** + * Tear down after each test. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create('\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); + $this->objectManager->create('\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); + $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); + + // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331 + $this->objectManager->create( + 'Magento\Core\Test\TestStep\SetupConfigurationStep', + ['configData' => 'default_tax_configuration'] + )->run(); + } } From 7ee2df5b8a55ed3bad5029359d4b17daa1eb0c3d Mon Sep 17 00:00:00 2001 From: vsevostianov Date: Tue, 20 Jan 2015 13:01:26 +0200 Subject: [PATCH 17/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - Moved tests to correct repo --- .../DownloadableTaxCalculationTest.php | 72 ------------------- .../DownloadableTaxCalculationTest/test.csv | 7 -- .../Downloadable/Test/etc/scenario.xml | 37 ---------- .../app/Magento/Tax/Test/etc/scenario.xml | 37 ---------- 4 files changed, 153 deletions(-) delete mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php delete mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv delete mode 100644 dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php deleted file mode 100644 index c810efd779521..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest.php +++ /dev/null @@ -1,72 +0,0 @@ - Taxes > Tax Rules. - * 3. Click 'Add New Tax Rule' button. - * 4. Assign default rates to rule. - * 5. Save Tax Rate. - * 6. Go to Products > Catalog. - * 7. Add new product. - * 8. Fill data according to dataset. - * 9. Save product. - * 10. Go to Stores > Configuration. - * 11. Fill Tax configuration according to data set. - * 12. Save tax configuration. - * 13. Perform all assertions. - * - * @group Tax_(CS) - * @ZephyrId MAGETWO-32076 - */ -class DownloadableTaxCalculationTest extends Scenario -{ - /** - * Skip failed tests. - * - * @return void - */ - public static function setUpBeforeClass() - { - self::markTestIncomplete("Epic: MAGETWO-30073"); - } - - /** - * Runs tax calculation test. - * - * @return void - */ - public function test() - { - $this->executeScenario(); - } - - /** - * Tear down after each test. - * - * @return void - */ - public function tearDown() - { - $this->objectManager->create('\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep')->run(); - $this->objectManager->create('\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep')->run(); - $this->objectManager->create('\Magento\CatalogRule\Test\TestStep\DeleteAllCatalogRulesStep')->run(); - - // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331 - $this->objectManager->create( - 'Magento\Core\Test\TestStep\SetupConfigurationStep', - ['configData' => 'default_tax_configuration'] - )->run(); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv deleted file mode 100644 index c8778e2a9f07e..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/DownloadableTaxCalculationTest/test.csv +++ /dev/null @@ -1,7 +0,0 @@ -"description";"configData";"product";"salesRule";"catalogRule";"taxRule";"customer/dataSet";"qty";"prices/category_price_excl_tax";"prices/category_price_incl_tax";"prices/product_view_price_excl_tax";"prices/product_view_price_incl_tax";"prices/cart_item_price_excl_tax";"prices/cart_item_price_incl_tax";"prices/cart_item_subtotal_excl_tax";"prices/cart_item_subtotal_incl_tax";"prices/subtotal_excl_tax";"prices/subtotal_incl_tax";"prices/discount";"prices/shipping_excl_tax";"prices/shipping_incl_tax";"prices/tax";"prices/grand_total_excl_tax";"prices/grand_total_incl_tax";"constraint";"issue" -"Downloadable product with sales rule, customer tax equals store tax and catalog price excluding tax";"total_cat_excl_ship_incl_after_disc_on_incl_disp_excl_incl";"downloadableProductInjectable::with_two_separately_links_special_price_and_category";"active_sales_rule_for_all_groups_no_coupon";"-";"customer_equals_store_rate";"johndoe_unique";"-";"20.00";"21.65";"23.00";"24.90";"23.00";"24.90";"23.00";"24.90";"23.00";"24.90";"12.45";"";"";"0.87";"10.55";"11.42";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax, assertOrderTaxOnBackendExcludingIncludingTax";"MAGETWO-32057" -"Downloadable product with catalog rule, customer tax greater than store tax and catalog price excluding tax";"total_cat_excl_ship_incl_after_disc_on_incl_disp_incl";"downloadableProductInjectable::with_two_separately_links_special_price_and_category";"-";"catalog_price_rule_all_groups";"customer_greater_store_rate";"johndoe_unique";"-";"";"16.26";"";"19.51";"";"19.51";"";"19.51";"";"19.51";"";"";"";"1.51";"18.00";"19.51";"assertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax, assertTaxCalculationAfterCheckoutDownloadableIncludingTax, assertOrderTaxOnBackendIncludingTax";"" -"Downloadable product with sales rule, customer tax less than store tax and catalog price excluding tax";"total_cat_excl_ship_incl_after_disc_on_incl_disp_excl";"downloadableProductInjectable::with_two_separately_links_group_price_and_category";"active_sales_rule_for_all_groups_no_coupon";"-";"customer_less_store_rate";"johndoe_unique";"-";"20.00";"";"23.00";"";"23.00";"";"23.00";"";"23.00";"";"12.45";"";"";"0.87";"11.42";"";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingTax, assertOrderTaxOnBackendExcludingTax";"" -"Downloadable product with catalog rule, customer tax greater than store tax and catalog price including tax";"total_cat_incl_ship_excl_before_disc_on_excl_disp_excl_incl";"downloadableProductInjectable::with_two_separately_links_custom_options_and_category";"-";"catalog_price_rule_all_groups";"customer_greater_store_rate";"johndoe_unique";"-";"9.24";"10.01";"12.01";"13.01";"12.01";"13.02";"12.01";"13.02";"12.01";"13.02";"";"";"";"1.01";"12.01";"13.02";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingIncludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingIncludingTax, assertOrderTaxOnBackendExcludingIncludingTax";"MAGETWO-32057" -"Downloadable product with sales rule, customer tax less than store tax and catalog price including tax";"total_cat_incl_ship_excl_before_disc_on_excl_disp_incl";"downloadableProductInjectable::with_two_separately_links_group_price_and_category";"active_sales_rule_for_all_groups_no_coupon";"-";"customer_less_store_rate";"johndoe_unique";"-";"";"19.98";"";"22.98";"";"22.97";"";"22.97";"";"22.97";"10.61";"";"";"1.75";"10.61";"12.36";"assertTaxRuleIsAppliedToAllPricesDownloadableIncludingTax, assertTaxCalculationAfterCheckoutDownloadableIncludingTax, assertOrderTaxOnBackendIncludingTax";"" -"Downloadable product with catalog rule, customer tax equals store tax and catalog price including tax";"total_cat_incl_ship_excl_before_disc_on_excl_disp_excl";"downloadableProductInjectable::with_two_separately_links_custom_options_and_category";"-";"catalog_price_rule_all_groups";"customer_equals_store_rate";"johndoe_unique";"-";"9.24";"";"12.01";"";"12.01";"";"12.01";"";"12.01";"";"";"";"";"0.99";"13.00";"";"assertTaxRuleIsAppliedToAllPricesDownloadableExcludingTax, assertTaxCalculationAfterCheckoutDownloadableExcludingTax, assertOrderTaxOnBackendExcludingTax";"MAGETWO-32057" \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml deleted file mode 100644 index d5d21016c52c8..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/etc/scenario.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - setupConfiguration - - createSalesRule - - - createCatalogRule - - - createTaxRule - - - createProduct - - - createCustomer - - - loginCustomerOnFrontend - - - - - - - diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml deleted file mode 100644 index 356993adf01e1..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/etc/scenario.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - setupConfiguration - - createSalesRule - - - createCatalogRule - - - createTaxRule - - - createProduct - - - createCustomer - - - loginCustomerOnFrontend - - - - - - - From 37d89b4e590c1e18699db0b5e702f36c6deb4cf0 Mon Sep 17 00:00:00 2001 From: Mike Weis Date: Tue, 20 Jan 2015 17:22:14 -0600 Subject: [PATCH 18/18] MAGETWO-29712: [QA] Automate downloadable with taxes test cases - fix functional test --- .../Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php index 0a3ab3efe4c27..7038e02eb5d19 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php @@ -6,8 +6,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order; -use Mtf\Block\Block; -use Mtf\Client\Locator; +use Mtf\Block\Form; /** * Class Form