Skip to content

Commit 8e3ca1f

Browse files
author
Kolesov, Ievgen(ikolesov)
committed
Merge pull request #88 from magento-south/BUGS
[South] Bug fixes
2 parents e8ff866 + 8098789 commit 8e3ca1f

File tree

8 files changed

+228
-2
lines changed

8 files changed

+228
-2
lines changed

app/code/Magento/CustomerImportExport/etc/import.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
<entity name="customer_composite" label="Customers and Addresses (single file)" model="Magento\CustomerImportExport\Model\Import\CustomerComposite" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />
1010
<entity name="customer" label="Customers Main File" model="Magento\CustomerImportExport\Model\Import\Customer" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Custom" />
1111
<entity name="customer_address" label="Customer Addresses" model="Magento\CustomerImportExport\Model\Import\Address" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Custom" />
12+
<relatedIndexer entity="customer" name="customer_grid" />
13+
<relatedIndexer entity="customer_address" name="customer_grid" />
14+
<relatedIndexer entity="customer_composite" name="customer_grid" />
1215
</config>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
email,_website,_store,confirmation,created_at,created_in,disable_auto_group_change,dob,firstname,gender,group_id,lastname,middlename,password_hash,prefix,reward_update_notification,reward_warning_notification,rp_token,rp_token_created_at,store_id,suffix,taxvat,updated_at,website_id,password
2+
jondoe@example.com,base,default,,"2015-10-30 12:49:47","Default Store View",0,,Jon,,1,Doe,,d708be3fe0fe0120840e8b13c8faae97424252c6374227ff59c05814f1aecd79:mgLqkqgTwLPLlCljzvF8hp67fNOOvOZb:1,,,,07e71459c137f4da15292134ff459cba,"2015-10-30 12:49:48",1,,,"2015-10-30 12:49:48",1,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_website,_email,_entity_id,city,company,country_id,fax,firstname,lastname,middlename,postcode,prefix,region,region_id,street,suffix,telephone,vat_id,vat_is_valid,vat_request_date,vat_request_id,vat_request_success,_address_default_billing_,_address_default_shipping_
2+
base,jondoe@example.com,1,"New York",,US,,Jon,Doe,,10044,,"New York",43,"Main Street 1",,123456789,,,,,,1,1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_email,_website,_finance_website,store_credit,reward_points
2+
jondoe@example.com,base,base,10.0000,100

app/code/Magento/ImportExport/Model/Import/Config/Reader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
1515
protected $_idAttributes = [
1616
'/config/entity' => 'name',
1717
'/config/entityType' => ['entity', 'name'],
18-
'/config/relatedIndexers' => ['entity', 'name'],
18+
'/config/relatedIndexer' => ['entity', 'name'],
1919
];
2020

2121
/**

app/code/Magento/Quote/Model/Quote/Address/Total/Shipping.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public function collect(
171171
$total->setBaseTotalAmount($this->getCode(), $rate->getPrice());
172172
$shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
173173
$address->setShippingDescription(trim($shippingDescription, ' -'));
174+
$total->setShippingAmount($rate->getPrice());
175+
$total->setShippingDescription($address->getShippingDescription());
174176
break;
175177
}
176178
}
@@ -184,6 +186,7 @@ public function collect(
184186
* @param \Magento\Quote\Model\Quote $quote
185187
* @param \Magento\Quote\Model\Quote\Address\Total $total
186188
* @return array
189+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
187190
*/
188191
public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
189192
{

app/code/Magento/Quote/Model/Quote/TotalsCollector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ public function collect(\Magento\Quote\Model\Quote $quote)
143143
foreach ($quote->getAllAddresses() as $address) {
144144
$addressTotal = $this->collectAddressTotals($quote, $address);
145145

146+
$total->setShippingAmount($addressTotal->getShippingAmount());
147+
$total->setBaseShippingAmount($addressTotal->getBaseShippingAmount());
148+
$total->setShippingDescription($addressTotal->getShippingDescription());
149+
146150
$total->setSubtotal((float)$total->getSubtotal() + $addressTotal->getSubtotal());
147151
$total->setBaseSubtotal((float)$total->getBaseSubtotal() + $addressTotal->getBaseSubtotal());
148152

app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/ShippingTest.php

Lines changed: 211 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,124 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
1212
*/
1313
protected $shippingModel;
1414

15+
/** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject */
16+
protected $quote;
17+
18+
/** @var \Magento\Quote\Model\Quote\Address\Total|\PHPUnit_Framework_MockObject_MockObject */
19+
protected $total;
20+
21+
/** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface|\PHPUnit_Framework_MockObject_MockObject */
22+
protected $shippingAssignment;
23+
24+
/** @var \Magento\Quote\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject */
25+
protected $address;
26+
27+
/** @var \Magento\Quote\Api\Data\ShippingInterface|\PHPUnit_Framework_MockObject_MockObject */
28+
protected $shipping;
29+
30+
/** @var \Magento\Quote\Model\Quote\Address\FreeShippingInterface|\PHPUnit_Framework_MockObject_MockObject */
31+
protected $freeShipping;
32+
33+
/** @var \Magento\Quote\Api\Data\CartItemInterface|\PHPUnit_Framework_MockObject_MockObject */
34+
protected $cartItem;
35+
36+
/** @var \Magento\Quote\Model\Quote\Address\Rate|\PHPUnit_Framework_MockObject_MockObject */
37+
protected $rate;
38+
39+
/** @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */
40+
protected $store;
41+
42+
/** @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject */
43+
protected $priceCurrency;
44+
1545
protected function setUp()
1646
{
47+
$this->freeShipping = $this->getMockForAbstractClass(
48+
'Magento\Quote\Model\Quote\Address\FreeShippingInterface',
49+
[],
50+
'',
51+
false
52+
);
53+
$this->priceCurrency = $this->getMockForAbstractClass(
54+
'Magento\Framework\Pricing\PriceCurrencyInterface',
55+
[],
56+
'',
57+
false
58+
);
1759
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
18-
$this->shippingModel = $objectManager->getObject('Magento\Quote\Model\Quote\Address\Total\Shipping');
60+
$this->shippingModel = $objectManager->getObject(
61+
'Magento\Quote\Model\Quote\Address\Total\Shipping',
62+
[
63+
'freeShipping' => $this->freeShipping,
64+
'priceCurrency' => $this->priceCurrency,
65+
]
66+
);
67+
68+
$this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
69+
$this->total = $this->getMock(
70+
'Magento\Quote\Model\Quote\Address\Total',
71+
[
72+
'setShippingAmount',
73+
'setBaseTotalAmount',
74+
'setTotalAmount',
75+
'setShippingDescription',
76+
],
77+
[],
78+
'',
79+
false
80+
);
81+
$this->shippingAssignment = $this->getMockForAbstractClass(
82+
'Magento\Quote\Api\Data\ShippingAssignmentInterface',
83+
[],
84+
'',
85+
false
86+
);
87+
$this->address = $this->getMock(
88+
'Magento\Quote\Model\Quote\Address',
89+
[
90+
'setWeight',
91+
'setFreeMethodWeight',
92+
'getWeight',
93+
'getFreeMethodWeight',
94+
'setFreeShipping',
95+
'setItemQty',
96+
'collectShippingRates',
97+
'getAllShippingRates',
98+
'setShippingDescription',
99+
'getShippingDescription',
100+
'getFreeShipping',
101+
],
102+
[],
103+
'',
104+
false
105+
);
106+
$this->shipping = $this->getMockForAbstractClass('Magento\Quote\Api\Data\ShippingInterface', [], '', false);
107+
$this->cartItem = $this->getMockForAbstractClass(
108+
'Magento\Quote\Api\Data\CartItemInterface',
109+
[],
110+
'',
111+
false,
112+
false,
113+
true,
114+
[
115+
'getFreeShipping',
116+
'getProduct',
117+
'getParentItem',
118+
'getHasChildren',
119+
'isVirtual',
120+
'getWeight',
121+
'getQty',
122+
'setRowWeight',
123+
]
124+
);
125+
$this->rate = $this->getMock(
126+
'Magento\Quote\Model\Quote\Address\Rate',
127+
['getPrice', 'getCode', 'getCarrierTitle', 'getMethodTitle'],
128+
[],
129+
'',
130+
false
131+
);
132+
$this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
19133
}
20134

21135
public function testFetch()
@@ -41,4 +155,100 @@ public function testFetch()
41155
$totalMock->expects($this->once())->method('getShippingDescription')->willReturn($shippingDescription);
42156
$this->assertEquals($expectedResult, $this->shippingModel->fetch($quoteMock, $totalMock));
43157
}
158+
159+
public function testCollect()
160+
{
161+
$this->shippingAssignment->expects($this->exactly(3))
162+
->method('getShipping')
163+
->willReturn($this->shipping);
164+
$this->shipping->expects($this->exactly(2))
165+
->method('getAddress')
166+
->willReturn($this->address);
167+
$this->shipping->expects($this->once())
168+
->method('getMethod')
169+
->willReturn('flatrate');
170+
$this->shippingAssignment->expects($this->atLeastOnce())
171+
->method('getItems')
172+
->willReturn([$this->cartItem]);
173+
$this->freeShipping->expects($this->once())
174+
->method('isFreeShipping')
175+
->with($this->quote, [$this->cartItem])
176+
->willReturn(true);
177+
$this->address->expects($this->once())
178+
->method('setFreeShipping')
179+
->with(true);
180+
$this->total->expects($this->atLeastOnce())
181+
->method('setTotalAmount');
182+
$this->total->expects($this->atLeastOnce())
183+
->method('setBaseTotalAmount');
184+
$this->cartItem->expects($this->atLeastOnce())
185+
->method('getProduct')
186+
->willReturnSelf();
187+
$this->cartItem->expects($this->atLeastOnce())
188+
->method('isVirtual')
189+
->willReturn(false);
190+
$this->cartItem->expects($this->once())
191+
->method('getParentItem')
192+
->willReturn(false);
193+
$this->cartItem->expects($this->once())
194+
->method('getHasChildren')
195+
->willReturn(false);
196+
$this->cartItem->expects($this->once())
197+
->method('getWeight')
198+
->willReturn(2);
199+
$this->cartItem->expects($this->atLeastOnce())
200+
->method('getQty')
201+
->willReturn(2);
202+
$this->address->expects($this->once())
203+
->method('getFreeShipping')
204+
->willReturn(true);
205+
$this->cartItem->expects($this->once())
206+
->method('setRowWeight')
207+
->with(0);
208+
$this->address->expects($this->once())
209+
->method('setItemQty')
210+
->with(2);
211+
$this->address->expects($this->atLeastOnce())
212+
->method('setWeight');
213+
$this->address->expects($this->atLeastOnce())
214+
->method('setFreeMethodWeight');
215+
$this->address->expects($this->once())
216+
->method('collectShippingRates');
217+
$this->address->expects($this->once())
218+
->method('getAllShippingRates')
219+
->willReturn([$this->rate]);
220+
$this->rate->expects($this->once())
221+
->method('getCode')
222+
->willReturn('flatrate');
223+
$this->quote->expects($this->once())
224+
->method('getStore')
225+
->willReturn($this->store);
226+
$this->rate->expects($this->atLeastOnce())
227+
->method('getPrice')
228+
->willReturn(5);
229+
$this->priceCurrency->expects($this->once())
230+
->method('convert')
231+
->with(5, $this->store)
232+
->willReturn(5);
233+
$this->total->expects($this->once())
234+
->method('setShippingAmount')
235+
->with(5);
236+
$this->rate->expects($this->once())
237+
->method('getCarrierTitle')
238+
->willReturn('Carrier title');
239+
$this->rate->expects($this->once())
240+
->method('getMethodTitle')
241+
->willReturn('Method title');
242+
$this->address->expects($this->once())
243+
->method('setShippingDescription')
244+
->with('Carrier title - Method title');
245+
$this->address->expects($this->once())
246+
->method('getShippingDescription')
247+
->willReturn('Carrier title - Method title');
248+
$this->total->expects($this->once())
249+
->method('setShippingDescription')
250+
->with('Carrier title - Method title');
251+
252+
$this->shippingModel->collect($this->quote, $this->shippingAssignment, $this->total);
253+
}
44254
}

0 commit comments

Comments
 (0)