Skip to content

Commit 93e44f8

Browse files
committed
Store data in a separate file #10790
1 parent 35ec386 commit 93e44f8

File tree

2 files changed

+138
-124
lines changed

2 files changed

+138
-124
lines changed

dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/TaxTest.php

Lines changed: 6 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
require_once __DIR__ . '/SetupUtil.php';
1212
require_once __DIR__ . '/../../../../_files/tax_calculation_data_aggregated.php';
13+
require_once __DIR__ . '/../../../../_files/full_discount_with_tax.php';
1314

1415
/**
1516
* Class TaxTest
@@ -115,135 +116,16 @@ public function testCollect()
115116
* This method will test the collector through $quote->collectTotals() method
116117
*
117118
* @see \Magento\SalesRule\Model\Utility::deltaRoundingFix
119+
* @magentoDataFixture Magento/Tax/_files/full_discount_with_tax.php
118120
* @magentoDbIsolation enabled
119121
* @magentoAppIsolation enabled
120122
*/
121123
public function testFullDiscountWithDeltaRoundingFix()
122124
{
123-
$configData = [
124-
'config_overrides' =>
125-
[
126-
'tax/calculation/apply_after_discount' => 0,
127-
'tax/calculation/discount_tax' => 1,
128-
'tax/calculation/algorithm' => 'ROW_BASE_CALCULATION',
129-
'tax/classes/shipping_tax_class' => SetupUtil::SHIPPING_TAX_CLASS,
130-
],
131-
'tax_rate_overrides' =>
132-
[
133-
SetupUtil::TAX_RATE_TX => 18,
134-
SetupUtil::TAX_RATE_SHIPPING => 0,
135-
],
136-
'tax_rule_overrides' =>
137-
[
138-
[
139-
'code' => 'Product Tax Rule',
140-
'product_tax_class_ids' =>
141-
[
142-
SetupUtil::PRODUCT_TAX_CLASS_1
143-
],
144-
],
145-
[
146-
'code' => 'Shipping Tax Rule',
147-
'product_tax_class_ids' =>
148-
[
149-
SetupUtil::SHIPPING_TAX_CLASS
150-
],
151-
'tax_rate_ids' =>
152-
[
153-
SetupUtil::TAX_RATE_SHIPPING,
154-
],
155-
],
156-
],
157-
];
158-
159-
$quoteData = [
160-
'billing_address' =>
161-
[
162-
'region_id' => SetupUtil::REGION_TX,
163-
],
164-
'shipping_address' =>
165-
[
166-
'region_id' => SetupUtil::REGION_TX,
167-
],
168-
'items' =>
169-
[
170-
[
171-
'sku' => 'simple1',
172-
'price' => 2542.37,
173-
'qty' => 2,
174-
]
175-
],
176-
'shipping_method' => 'free',
177-
'shopping_cart_rules' =>
178-
[
179-
['discount_amount' => 100],
180-
],
181-
];
182-
183-
$expectedResults = [
184-
'address_data' =>
185-
[
186-
'subtotal' => 5084.74,
187-
'base_subtotal' => 5084.74,
188-
'subtotal_incl_tax' => 5999.99,
189-
'base_subtotal_incl_tax' => 5999.99,
190-
'tax_amount' => 915.25,
191-
'base_tax_amount' => 915.25,
192-
'shipping_amount' => 0,
193-
'base_shipping_amount' => 0,
194-
'shipping_incl_tax' => 0,
195-
'base_shipping_incl_tax' => 0,
196-
'shipping_tax_amount' => 0,
197-
'base_shipping_tax_amount' => 0,
198-
'discount_amount' => -5999.99,
199-
'base_discount_amount' => -5999.99,
200-
'discount_tax_compensation_amount' => 0,
201-
'base_discount_tax_compensation_amount' => 0,
202-
'shipping_discount_tax_compensation_amount' => 0,
203-
'base_shipping_discount_tax_compensation_amount' => 0,
204-
'grand_total' => 0,
205-
'base_grand_total' => 0,
206-
'applied_taxes' =>
207-
[
208-
SetupUtil::TAX_RATE_TX =>
209-
[
210-
'percent' => 18,
211-
'amount' => 915.25,
212-
'base_amount' => 915.25,
213-
'rates' =>
214-
[
215-
[
216-
'code' => SetupUtil::TAX_RATE_TX,
217-
'title' => SetupUtil::TAX_RATE_TX,
218-
'percent' => 18,
219-
],
220-
],
221-
]
222-
],
223-
],
224-
'items_data' =>
225-
[
226-
'simple1' =>
227-
[
228-
'row_total' => 5084.74,
229-
'base_row_total' => 5084.74,
230-
'tax_percent' => 18,
231-
'price' => 2542.37,
232-
'base_price' => 2542.37,
233-
'price_incl_tax' => 3000,
234-
'base_price_incl_tax' => 3000,
235-
'row_total_incl_tax' => 5999.99,
236-
'base_row_total_incl_tax' => 5999.99,
237-
'tax_amount' => 915.25,
238-
'base_tax_amount' => 915.25,
239-
'discount_amount' => 5999.99,
240-
'base_discount_amount' => 5999.99,
241-
'discount_percent' => 100,
242-
'discount_tax_compensation_amount' => 0,
243-
'base_discount_tax_compensation_amount' => 0,
244-
],
245-
],
246-
];
125+
global $fullTaxDiscountWithTax;
126+
$configData = $fullTaxDiscountWithTax['config_data'];
127+
$quoteData = $fullTaxDiscountWithTax['quote_data'];
128+
$expectedResults = $fullTaxDiscountWithTax['expected_result'];
247129

248130
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
249131
$objectManager = Bootstrap::getObjectManager();
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
use Magento\Tax\Model\Config;
7+
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
8+
9+
$fullTaxDiscountWithTax = [
10+
'config_data' => [
11+
'config_overrides' =>
12+
[
13+
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 0,
14+
Config::CONFIG_XML_PATH_DISCOUNT_TAX => 1,
15+
Config::XML_PATH_ALGORITHM => 'ROW_BASE_CALCULATION',
16+
Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::SHIPPING_TAX_CLASS,
17+
],
18+
'tax_rate_overrides' =>
19+
[
20+
SetupUtil::TAX_RATE_TX => 18,
21+
SetupUtil::TAX_RATE_SHIPPING => 0,
22+
],
23+
'tax_rule_overrides' =>
24+
[
25+
[
26+
'code' => 'Product Tax Rule',
27+
'product_tax_class_ids' =>
28+
[
29+
SetupUtil::PRODUCT_TAX_CLASS_1
30+
],
31+
],
32+
[
33+
'code' => 'Shipping Tax Rule',
34+
'product_tax_class_ids' =>
35+
[
36+
SetupUtil::SHIPPING_TAX_CLASS
37+
],
38+
'tax_rate_ids' =>
39+
[
40+
SetupUtil::TAX_RATE_SHIPPING,
41+
],
42+
],
43+
],
44+
],
45+
'quote_data' => [
46+
'billing_address' =>
47+
[
48+
'region_id' => SetupUtil::REGION_TX,
49+
],
50+
'shipping_address' =>
51+
[
52+
'region_id' => SetupUtil::REGION_TX,
53+
],
54+
'items' =>
55+
[
56+
[
57+
'sku' => 'simple1',
58+
'price' => 2542.37,
59+
'qty' => 2,
60+
]
61+
],
62+
'shipping_method' => 'free',
63+
'shopping_cart_rules' =>
64+
[
65+
['discount_amount' => 100],
66+
],
67+
],
68+
'expected_result' => [
69+
'address_data' =>
70+
[
71+
'subtotal' => 5084.74,
72+
'base_subtotal' => 5084.74,
73+
'subtotal_incl_tax' => 5999.99,
74+
'base_subtotal_incl_tax' => 5999.99,
75+
'tax_amount' => 915.25,
76+
'base_tax_amount' => 915.25,
77+
'shipping_amount' => 0,
78+
'base_shipping_amount' => 0,
79+
'shipping_incl_tax' => 0,
80+
'base_shipping_incl_tax' => 0,
81+
'shipping_tax_amount' => 0,
82+
'base_shipping_tax_amount' => 0,
83+
'discount_amount' => -5999.99,
84+
'base_discount_amount' => -5999.99,
85+
'discount_tax_compensation_amount' => 0,
86+
'base_discount_tax_compensation_amount' => 0,
87+
'shipping_discount_tax_compensation_amount' => 0,
88+
'base_shipping_discount_tax_compensation_amount' => 0,
89+
'grand_total' => 0,
90+
'base_grand_total' => 0,
91+
'applied_taxes' =>
92+
[
93+
SetupUtil::TAX_RATE_TX =>
94+
[
95+
'percent' => 18,
96+
'amount' => 915.25,
97+
'base_amount' => 915.25,
98+
'rates' =>
99+
[
100+
[
101+
'code' => SetupUtil::TAX_RATE_TX,
102+
'title' => SetupUtil::TAX_RATE_TX,
103+
'percent' => 18,
104+
],
105+
],
106+
]
107+
],
108+
],
109+
'items_data' =>
110+
[
111+
'simple1' =>
112+
[
113+
'row_total' => 5084.74,
114+
'base_row_total' => 5084.74,
115+
'tax_percent' => 18,
116+
'price' => 2542.37,
117+
'base_price' => 2542.37,
118+
'price_incl_tax' => 3000,
119+
'base_price_incl_tax' => 3000,
120+
'row_total_incl_tax' => 5999.99,
121+
'base_row_total_incl_tax' => 5999.99,
122+
'tax_amount' => 915.25,
123+
'base_tax_amount' => 915.25,
124+
'discount_amount' => 5999.99,
125+
'base_discount_amount' => 5999.99,
126+
'discount_percent' => 100,
127+
'discount_tax_compensation_amount' => 0,
128+
'base_discount_tax_compensation_amount' => 0,
129+
],
130+
],
131+
]
132+
];

0 commit comments

Comments
 (0)