Skip to content

Commit c6615dd

Browse files
committed
MAGETWO-61091: [Backport] - [Github] Free Shipping Method not showing in backend #2939 - for 2.0
1 parent 4ac2029 commit c6615dd

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ protected function processProductItems(
536536
$total->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
537537
$total->setBaseSubtotalInclTax($baseSubtotalInclTax);
538538

539+
$shippingAssignment->getShipping()->getAddress()->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
540+
539541
return $this;
540542
}
541543

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

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ class SubtotalTest extends \PHPUnit_Framework_TestCase
2525
protected function setUp()
2626
{
2727
$this->objectManager = Bootstrap::getObjectManager();
28+
$this->productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
2829
}
2930

3031
protected function getCustomerById($id)
3132
{
3233
/**
3334
* @var $customerRepository \Magento\Customer\Api\CustomerRepositoryInterface
3435
*/
35-
$customerRepository = $this->objectManager->create('Magento\Customer\Api\CustomerRepositoryInterface');
36+
$customerRepository = $this->objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
3637
return $customerRepository->getById($id);
3738
}
3839

@@ -51,10 +52,10 @@ public function testCollectUnitBased($expected)
5152
$customerTaxClassId = $this->getCustomerTaxClassId();
5253
$fixtureCustomerId = 1;
5354
/** @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);
5556
/** @var \Magento\Customer\Model\Group $customerGroup */
5657
$customerGroup = $this->objectManager->create(
57-
'Magento\Customer\Model\Group'
58+
\Magento\Customer\Model\Group::class
5859
)->load(
5960
'custom_group',
6061
'customer_group_code'
@@ -65,18 +66,18 @@ public function testCollectUnitBased($expected)
6566
$productTaxClassId = $this->getProductTaxClassId();
6667
$fixtureProductId = 1;
6768
/** @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);
6970
$product->setTaxClassId($productTaxClassId)->save();
7071

7172
$quoteShippingAddressDataObject = $this->getShippingAddressDataObject($fixtureCustomerId);
7273

7374
/** @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);
7576
$quoteShippingAddress->importCustomerAddressData($quoteShippingAddressDataObject);
7677
$quantity = 2;
7778

7879
/** @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);
8081
$quote->setStoreId(
8182
1
8283
)->setIsActive(
@@ -99,23 +100,24 @@ public function testCollectUnitBased($expected)
99100
);
100101
$address = $quote->getShippingAddress();
101102
/** @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);
104105
$shipping->setAddress($address);
105106
$shippingAssignment->setShipping($shipping);
106107
$shippingAssignment->setItems($address->getAllItems());
107108
/** @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);
109110
/** @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);
111112
$addressSubtotalCollector->collect($quote, $shippingAssignment, $total);
112113

113114
/** @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);
115116
$subtotalCollector->collect($quote, $shippingAssignment, $total);
116117

117118
$this->assertEquals($expected['subtotal'], $total->getSubtotal());
118119
$this->assertEquals($expected['subtotal'] + $expected['tax_amount'], $total->getSubtotalInclTax());
120+
$this->assertEquals($expected['subtotal'] + $expected['tax_amount'], $address->getBaseSubtotalTotalInclTax());
119121
$this->assertEquals($expected['discount_amount'], $total->getDiscountAmount());
120122
$items = $address->getAllItems();
121123
/** @var \Magento\Quote\Model\Quote\Address\Item $item */
@@ -167,10 +169,10 @@ public function testCollectUnitBasedBundleProduct($expected)
167169
$customerTaxClassId = $this->getCustomerTaxClassId();
168170
$fixtureCustomerId = 1;
169171
/** @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);
171173
/** @var \Magento\Customer\Model\Group $customerGroup */
172174
$customerGroup = $this->objectManager->create(
173-
'Magento\Customer\Model\Group'
175+
\Magento\Customer\Model\Group::class
174176
)->load(
175177
'custom_group',
176178
'customer_group_code'
@@ -181,24 +183,24 @@ public function testCollectUnitBasedBundleProduct($expected)
181183
$productTaxClassId = $this->getProductTaxClassId();
182184
$fixtureChildProductId = 1;
183185
/** @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);
185187
$childProduct->setTaxClassId($productTaxClassId)->save();
186188
$fixtureProductId = 3;
187189
/** @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);
189191
$product->setTaxClassId($productTaxClassId)
190192
->setPriceType(\Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD)
191193
->save();
192194

193195
$quoteShippingAddressDataObject = $this->getShippingAddressDataObject($fixtureCustomerId);
194196

195197
/** @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);
197199
$quoteShippingAddress->importCustomerAddressData($quoteShippingAddressDataObject);
198200
$quantity = 2;
199201

200202
/** @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);
202204
$quote->setStoreId(
203205
1
204206
)->setIsActive(
@@ -221,23 +223,24 @@ public function testCollectUnitBasedBundleProduct($expected)
221223
);
222224
$address = $quote->getShippingAddress();
223225
/** @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);
226228
$shipping->setAddress($address);
227229
$shippingAssignment->setShipping($shipping);
228230
$shippingAssignment->setItems($quote->getAllItems());
229231
/** @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);
231233
/** @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);
233235
$addressSubtotalCollector->collect($quote, $shippingAssignment, $total);
234236

235237
/** @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);
237239
$subtotalCollector->collect($quote, $shippingAssignment, $total);
238240

239241
$this->assertEquals($expected['subtotal'], $total->getSubtotal());
240242
$this->assertEquals($expected['subtotal'] + $expected['tax_amount'], $total->getSubtotalInclTax());
243+
$this->assertEquals($expected['subtotal'] + $expected['tax_amount'], $address->getBaseSubtotalTotalInclTax());
241244
$this->assertEquals($expected['discount_amount'], $total->getDiscountAmount());
242245
$items = $address->getAllItems();
243246
/** @var \Magento\Quote\Model\Quote\Address\Item $item */
@@ -255,7 +258,7 @@ public function testCollectUnitBasedBundleProduct($expected)
255258
*/
256259
protected function getCustomerTaxClassId()
257260
{
258-
$customerTaxClass = $this->objectManager->create('Magento\Tax\Model\ClassModel');
261+
$customerTaxClass = $this->objectManager->create(\Magento\Tax\Model\ClassModel::class);
259262
$fixtureCustomerTaxClass = 'CustomerTaxClass2';
260263
/** @var \Magento\Tax\Model\ClassModel $customerTaxClass */
261264
$customerTaxClass->load($fixtureCustomerTaxClass, 'class_name');
@@ -270,7 +273,7 @@ protected function getCustomerTaxClassId()
270273
protected function getProductTaxClassId()
271274
{
272275
/** @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);
274277
$fixtureProductTaxClass = 'ProductTaxClass1';
275278
$productTaxClass->load($fixtureProductTaxClass, 'class_name');
276279
return $productTaxClass->getId();
@@ -283,13 +286,13 @@ protected function getProductTaxClassId()
283286
protected function getShippingAddressDataObject($fixtureCustomerId)
284287
{
285288
$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);
287290
/** Set data which corresponds tax class fixture */
288291
$customerAddress->setCountryId('US')->setRegionId(12)->save();
289292
/**
290293
* @var $addressRepository \Magento\Customer\Api\AddressRepositoryInterface
291294
*/
292-
$addressRepository = $this->objectManager->get('Magento\Customer\Api\AddressRepositoryInterface');
295+
$addressRepository = $this->objectManager->get(\Magento\Customer\Api\AddressRepositoryInterface::class);
293296
$quoteShippingAddressDataObject = $addressRepository->getById($fixtureCustomerAddressId);
294297
return $quoteShippingAddressDataObject;
295298
}

0 commit comments

Comments
 (0)