@@ -25,14 +25,15 @@ class SubtotalTest extends \PHPUnit_Framework_TestCase
25
25
protected function setUp ()
26
26
{
27
27
$ this ->objectManager = Bootstrap::getObjectManager ();
28
+ $ this ->productRepository = $ this ->objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
28
29
}
29
30
30
31
protected function getCustomerById ($ id )
31
32
{
32
33
/**
33
34
* @var $customerRepository \Magento\Customer\Api\CustomerRepositoryInterface
34
35
*/
35
- $ customerRepository = $ this ->objectManager ->create (' Magento\Customer\Api\CustomerRepositoryInterface ' );
36
+ $ customerRepository = $ this ->objectManager ->create (\ Magento \Customer \Api \CustomerRepositoryInterface::class );
36
37
return $ customerRepository ->getById ($ id );
37
38
}
38
39
@@ -51,10 +52,10 @@ public function testCollectUnitBased($expected)
51
52
$ customerTaxClassId = $ this ->getCustomerTaxClassId ();
52
53
$ fixtureCustomerId = 1 ;
53
54
/** @var \Magento\Customer\Model\Customer $customer */
54
- $ customer = $ this ->objectManager ->create (' Magento\Customer\Model\Customer ' )->load ($ fixtureCustomerId );
55
+ $ customer = $ this ->objectManager ->create (\ Magento \Customer \Model \Customer::class )->load ($ fixtureCustomerId );
55
56
/** @var \Magento\Customer\Model\Group $customerGroup */
56
57
$ customerGroup = $ this ->objectManager ->create (
57
- ' Magento\Customer\Model\Group '
58
+ \ Magento \Customer \Model \Group::class
58
59
)->load (
59
60
'custom_group ' ,
60
61
'customer_group_code '
@@ -65,18 +66,18 @@ public function testCollectUnitBased($expected)
65
66
$ productTaxClassId = $ this ->getProductTaxClassId ();
66
67
$ fixtureProductId = 1 ;
67
68
/** @var \Magento\Catalog\Model\Product $product */
68
- $ product = $ this ->objectManager ->create (' Magento\Catalog\Model\Product ' )->load ($ fixtureProductId );
69
+ $ product = $ this ->objectManager ->create (\ Magento \Catalog \Model \Product::class )->load ($ fixtureProductId );
69
70
$ product ->setTaxClassId ($ productTaxClassId )->save ();
70
71
71
72
$ quoteShippingAddressDataObject = $ this ->getShippingAddressDataObject ($ fixtureCustomerId );
72
73
73
74
/** @var \Magento\Quote\Model\Quote\Address $quoteShippingAddress */
74
- $ quoteShippingAddress = $ this ->objectManager ->create (' Magento\Quote\Model\Quote\Address ' );
75
+ $ quoteShippingAddress = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote \Address::class );
75
76
$ quoteShippingAddress ->importCustomerAddressData ($ quoteShippingAddressDataObject );
76
77
$ quantity = 2 ;
77
78
78
79
/** @var \Magento\Quote\Model\Quote $quote */
79
- $ quote = $ this ->objectManager ->create (' Magento\Quote\Model\Quote ' );
80
+ $ quote = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote::class );
80
81
$ quote ->setStoreId (
81
82
1
82
83
)->setIsActive (
@@ -99,23 +100,24 @@ public function testCollectUnitBased($expected)
99
100
);
100
101
$ address = $ quote ->getShippingAddress ();
101
102
/** @var \Magento\Quote\Model\ShippingAssignment $shippingAssignment */
102
- $ shippingAssignment = $ this ->objectManager ->create (' Magento\Quote\Model\ShippingAssignment ' );
103
- $ shipping = $ this ->objectManager ->create (' Magento\Quote\Model\Shipping ' );
103
+ $ shippingAssignment = $ this ->objectManager ->create (\ Magento \Quote \Model \ShippingAssignment::class );
104
+ $ shipping = $ this ->objectManager ->create (\ Magento \Quote \Model \Shipping::class );
104
105
$ shipping ->setAddress ($ address );
105
106
$ shippingAssignment ->setShipping ($ shipping );
106
107
$ shippingAssignment ->setItems ($ address ->getAllItems ());
107
108
/** @var \Magento\Quote\Model\Quote\Address\Total $total */
108
- $ total = $ this ->objectManager ->create (' Magento\Quote\Model\Quote\Address\Total ' );
109
+ $ total = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote \Address \Total::class );
109
110
/** @var \Magento\Quote\Model\Quote\Address\Total\Subtotal $addressSubtotalCollector */
110
- $ addressSubtotalCollector = $ this ->objectManager ->create (' Magento\Quote\Model\Quote\Address\Total\Subtotal ' );
111
+ $ addressSubtotalCollector = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote \Address \Total \Subtotal::class );
111
112
$ addressSubtotalCollector ->collect ($ quote , $ shippingAssignment , $ total );
112
113
113
114
/** @var \Magento\Tax\Model\Sales\Total\Quote\Subtotal $subtotalCollector */
114
- $ subtotalCollector = $ this ->objectManager ->create (' Magento\Tax\Model\Sales\Total\Quote\Subtotal ' );
115
+ $ subtotalCollector = $ this ->objectManager ->create (\ Magento \Tax \Model \Sales \Total \Quote \Subtotal::class );
115
116
$ subtotalCollector ->collect ($ quote , $ shippingAssignment , $ total );
116
117
117
118
$ this ->assertEquals ($ expected ['subtotal ' ], $ total ->getSubtotal ());
118
119
$ this ->assertEquals ($ expected ['subtotal ' ] + $ expected ['tax_amount ' ], $ total ->getSubtotalInclTax ());
120
+ $ this ->assertEquals ($ expected ['subtotal ' ] + $ expected ['tax_amount ' ], $ address ->getBaseSubtotalTotalInclTax ());
119
121
$ this ->assertEquals ($ expected ['discount_amount ' ], $ total ->getDiscountAmount ());
120
122
$ items = $ address ->getAllItems ();
121
123
/** @var \Magento\Quote\Model\Quote\Address\Item $item */
@@ -167,10 +169,10 @@ public function testCollectUnitBasedBundleProduct($expected)
167
169
$ customerTaxClassId = $ this ->getCustomerTaxClassId ();
168
170
$ fixtureCustomerId = 1 ;
169
171
/** @var \Magento\Customer\Model\Customer $customer */
170
- $ customer = $ this ->objectManager ->create (' Magento\Customer\Model\Customer ' )->load ($ fixtureCustomerId );
172
+ $ customer = $ this ->objectManager ->create (\ Magento \Customer \Model \Customer::class )->load ($ fixtureCustomerId );
171
173
/** @var \Magento\Customer\Model\Group $customerGroup */
172
174
$ customerGroup = $ this ->objectManager ->create (
173
- ' Magento\Customer\Model\Group '
175
+ \ Magento \Customer \Model \Group::class
174
176
)->load (
175
177
'custom_group ' ,
176
178
'customer_group_code '
@@ -181,24 +183,24 @@ public function testCollectUnitBasedBundleProduct($expected)
181
183
$ productTaxClassId = $ this ->getProductTaxClassId ();
182
184
$ fixtureChildProductId = 1 ;
183
185
/** @var \Magento\Catalog\Model\Product $product */
184
- $ childProduct = $ this ->objectManager ->create (' Magento\Catalog\Model\Product ' )->load ($ fixtureChildProductId );
186
+ $ childProduct = $ this ->objectManager ->create (\ Magento \Catalog \Model \Product::class )->load ($ fixtureChildProductId );
185
187
$ childProduct ->setTaxClassId ($ productTaxClassId )->save ();
186
188
$ fixtureProductId = 3 ;
187
189
/** @var \Magento\Catalog\Model\Product $product */
188
- $ product = $ this ->objectManager ->create (' Magento\Catalog\Model\Product ' )->load ($ fixtureProductId );
190
+ $ product = $ this ->objectManager ->create (\ Magento \Catalog \Model \Product::class )->load ($ fixtureProductId );
189
191
$ product ->setTaxClassId ($ productTaxClassId )
190
192
->setPriceType (\Magento \Catalog \Model \Product \Type \AbstractType::CALCULATE_CHILD )
191
193
->save ();
192
194
193
195
$ quoteShippingAddressDataObject = $ this ->getShippingAddressDataObject ($ fixtureCustomerId );
194
196
195
197
/** @var \Magento\Quote\Model\Quote\Address $quoteShippingAddress */
196
- $ quoteShippingAddress = $ this ->objectManager ->create (' Magento\Quote\Model\Quote\Address ' );
198
+ $ quoteShippingAddress = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote \Address::class );
197
199
$ quoteShippingAddress ->importCustomerAddressData ($ quoteShippingAddressDataObject );
198
200
$ quantity = 2 ;
199
201
200
202
/** @var \Magento\Quote\Model\Quote $quote */
201
- $ quote = $ this ->objectManager ->create (' Magento\Quote\Model\Quote ' );
203
+ $ quote = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote::class );
202
204
$ quote ->setStoreId (
203
205
1
204
206
)->setIsActive (
@@ -221,23 +223,24 @@ public function testCollectUnitBasedBundleProduct($expected)
221
223
);
222
224
$ address = $ quote ->getShippingAddress ();
223
225
/** @var \Magento\Quote\Model\ShippingAssignment $shippingAssignment */
224
- $ shippingAssignment = $ this ->objectManager ->create (' Magento\Quote\Model\ShippingAssignment ' );
225
- $ shipping = $ this ->objectManager ->create (' Magento\Quote\Model\Shipping ' );
226
+ $ shippingAssignment = $ this ->objectManager ->create (\ Magento \Quote \Model \ShippingAssignment::class );
227
+ $ shipping = $ this ->objectManager ->create (\ Magento \Quote \Model \Shipping::class );
226
228
$ shipping ->setAddress ($ address );
227
229
$ shippingAssignment ->setShipping ($ shipping );
228
230
$ shippingAssignment ->setItems ($ quote ->getAllItems ());
229
231
/** @var \Magento\Quote\Model\Quote\Address\Total $total */
230
- $ total = $ this ->objectManager ->create (' Magento\Quote\Model\Quote\Address\Total ' );
232
+ $ total = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote \Address \Total::class );
231
233
/** @var \Magento\Quote\Model\Quote\Address\Total\Subtotal $addressSubtotalCollector */
232
- $ addressSubtotalCollector = $ this ->objectManager ->create (' Magento\Quote\Model\Quote\Address\Total\Subtotal ' );
234
+ $ addressSubtotalCollector = $ this ->objectManager ->create (\ Magento \Quote \Model \Quote \Address \Total \Subtotal::class );
233
235
$ addressSubtotalCollector ->collect ($ quote , $ shippingAssignment , $ total );
234
236
235
237
/** @var \Magento\Tax\Model\Sales\Total\Quote\Subtotal $subtotalCollector */
236
- $ subtotalCollector = $ this ->objectManager ->create (' Magento\Tax\Model\Sales\Total\Quote\Subtotal ' );
238
+ $ subtotalCollector = $ this ->objectManager ->create (\ Magento \Tax \Model \Sales \Total \Quote \Subtotal::class );
237
239
$ subtotalCollector ->collect ($ quote , $ shippingAssignment , $ total );
238
240
239
241
$ this ->assertEquals ($ expected ['subtotal ' ], $ total ->getSubtotal ());
240
242
$ this ->assertEquals ($ expected ['subtotal ' ] + $ expected ['tax_amount ' ], $ total ->getSubtotalInclTax ());
243
+ $ this ->assertEquals ($ expected ['subtotal ' ] + $ expected ['tax_amount ' ], $ address ->getBaseSubtotalTotalInclTax ());
241
244
$ this ->assertEquals ($ expected ['discount_amount ' ], $ total ->getDiscountAmount ());
242
245
$ items = $ address ->getAllItems ();
243
246
/** @var \Magento\Quote\Model\Quote\Address\Item $item */
@@ -255,7 +258,7 @@ public function testCollectUnitBasedBundleProduct($expected)
255
258
*/
256
259
protected function getCustomerTaxClassId ()
257
260
{
258
- $ customerTaxClass = $ this ->objectManager ->create (' Magento\Tax\Model\ClassModel ' );
261
+ $ customerTaxClass = $ this ->objectManager ->create (\ Magento \Tax \Model \ClassModel::class );
259
262
$ fixtureCustomerTaxClass = 'CustomerTaxClass2 ' ;
260
263
/** @var \Magento\Tax\Model\ClassModel $customerTaxClass */
261
264
$ customerTaxClass ->load ($ fixtureCustomerTaxClass , 'class_name ' );
@@ -270,7 +273,7 @@ protected function getCustomerTaxClassId()
270
273
protected function getProductTaxClassId ()
271
274
{
272
275
/** @var \Magento\Tax\Model\ClassModel $productTaxClass */
273
- $ productTaxClass = $ this ->objectManager ->create (' Magento\Tax\Model\ClassModel ' );
276
+ $ productTaxClass = $ this ->objectManager ->create (\ Magento \Tax \Model \ClassModel::class );
274
277
$ fixtureProductTaxClass = 'ProductTaxClass1 ' ;
275
278
$ productTaxClass ->load ($ fixtureProductTaxClass , 'class_name ' );
276
279
return $ productTaxClass ->getId ();
@@ -283,13 +286,13 @@ protected function getProductTaxClassId()
283
286
protected function getShippingAddressDataObject ($ fixtureCustomerId )
284
287
{
285
288
$ fixtureCustomerAddressId = 1 ;
286
- $ customerAddress = $ this ->objectManager ->create (' Magento\Customer\Model\Address ' )->load ($ fixtureCustomerId );
289
+ $ customerAddress = $ this ->objectManager ->create (\ Magento \Customer \Model \Address::class )->load ($ fixtureCustomerId );
287
290
/** Set data which corresponds tax class fixture */
288
291
$ customerAddress ->setCountryId ('US ' )->setRegionId (12 )->save ();
289
292
/**
290
293
* @var $addressRepository \Magento\Customer\Api\AddressRepositoryInterface
291
294
*/
292
- $ addressRepository = $ this ->objectManager ->get (' Magento\Customer\Api\AddressRepositoryInterface ' );
295
+ $ addressRepository = $ this ->objectManager ->get (\ Magento \Customer \Api \AddressRepositoryInterface::class );
293
296
$ quoteShippingAddressDataObject = $ addressRepository ->getById ($ fixtureCustomerAddressId );
294
297
return $ quoteShippingAddressDataObject ;
295
298
}
0 commit comments