Skip to content

Commit ebf8674

Browse files
author
Yevhen Miroshnychenko
committed
Merge branch '2.2-develop' into MAGETWO-84507
2 parents cb25aa4 + b17b9c9 commit ebf8674

File tree

9 files changed

+129
-10
lines changed

9 files changed

+129
-10
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ define([
7272
output = {},
7373
streetObject;
7474

75+
$.each(addrs, function (key) {
76+
if (addrs.hasOwnProperty(key) && !$.isFunction(addrs[key])) {
77+
output[self.toUnderscore(key)] = addrs[key];
78+
}
79+
});
80+
7581
if ($.isArray(addrs.street)) {
7682
streetObject = {};
7783
addrs.street.forEach(function (value, index) {
7884
streetObject[index] = value;
7985
});
80-
addrs.street = streetObject;
86+
output.street = streetObject;
8187
}
8288

83-
$.each(addrs, function (key) {
84-
if (addrs.hasOwnProperty(key) && !$.isFunction(addrs[key])) {
85-
output[self.toUnderscore(key)] = addrs[key];
86-
}
87-
});
88-
8989
return output;
9090
},
9191

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ public function requestShippingRates(\Magento\Quote\Model\Quote\Item\AbstractIte
10081008
/**
10091009
* Store and website identifiers specified from StoreManager
10101010
*/
1011+
$request->setQuoteStoreId($this->getQuote()->getStoreId());
10111012
$request->setStoreId($this->storeManager->getStore()->getId());
10121013
$request->setWebsiteId($this->storeManager->getWebsite()->getId());
10131014
$request->setFreeShipping($this->getFreeShipping());

app/code/Magento/Sales/Block/Order/Totals.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ public function removeTotal($code)
293293
*/
294294
public function applySortOrder($order)
295295
{
296+
\uksort(
297+
$this->_totals,
298+
function ($code1, $code2) use ($order) {
299+
return ($order[$code1] ?? 0) <=> ($order[$code2] ?? 0);
300+
}
301+
);
296302
return $this;
297303
}
298304

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\Unit\Block\Order;
7+
8+
use Magento\Framework\Registry;
9+
use Magento\Sales\Block\Order\Totals;
10+
use Magento\Sales\Model\Order;
11+
use Magento\Sales\Model\Order\Total;
12+
13+
class TotalsTest extends \PHPUnit\Framework\TestCase
14+
{
15+
/**
16+
* @var \Magento\Sales\Block\Order\Totals
17+
*/
18+
protected $block;
19+
20+
/**
21+
* @var \Magento\Framework\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
protected $context;
24+
25+
protected function setUp()
26+
{
27+
$this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
28+
$this->block = new Totals($this->context, new Registry);
29+
$this->block->setOrder($this->createMock(Order::class));
30+
}
31+
32+
public function testApplySortOrder()
33+
{
34+
$this->block->addTotal(new Total(['code' => 'one']), 'last');
35+
$this->block->addTotal(new Total(['code' => 'two']), 'last');
36+
$this->block->addTotal(new Total(['code' => 'three']), 'last');
37+
$this->block->applySortOrder(
38+
[
39+
'one' => 10,
40+
'two' => 30,
41+
'three' => 20,
42+
]
43+
);
44+
$this->assertEqualsSorted(
45+
[
46+
'one' => new Total(['code' => 'one']),
47+
'three' => new Total(['code' => 'three']),
48+
'two' => new Total(['code' => 'two']),
49+
],
50+
$this->block->getTotals()
51+
);
52+
}
53+
54+
private function assertEqualsSorted(array $expected, array $actual)
55+
{
56+
$this->assertEquals($expected, $actual, 'Array contents should be equal.');
57+
$this->assertEquals(array_keys($expected), array_keys($actual), 'Array sort order should be equal.');
58+
}
59+
}

app/code/Magento/Shipping/Model/Shipping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function collectRates(\Magento\Quote\Model\Quote\Address\RateRequest $req
252252
public function collectCarrierRates($carrierCode, $request)
253253
{
254254
/* @var $carrier \Magento\Shipping\Model\Carrier\AbstractCarrier */
255-
$carrier = $this->_carrierFactory->createIfActive($carrierCode, $request->getStoreId());
255+
$carrier = $this->_carrierFactory->createIfActive($carrierCode, $request->getQuoteStoreId());
256256
if (!$carrier) {
257257
return $this;
258258
}

app/code/Magento/Swatches/Helper/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected function setupImageProperties(\Magento\Framework\Image $image, $isSwat
207207
if ($isSwatch) {
208208
$image->keepFrame(true);
209209
$image->keepTransparency(true);
210-
$image->backgroundColor('#FFF');
210+
$image->backgroundColor([255, 255, 255]);
211211
}
212212
return $this;
213213
}

app/code/Magento/Swatches/Test/Unit/Helper/MediaTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public function testGenerateSwatchVariations()
166166
$this->imageFactoryMock->expects($this->any())->method('create')->willReturn($image);
167167
$this->generateImageConfig();
168168
$image->expects($this->any())->method('resize')->will($this->returnSelf());
169+
$image->expects($this->atLeastOnce())->method('backgroundColor')->with([255, 255, 255])->willReturnSelf();
169170
$this->mediaHelperObject->generateSwatchVariations('/e/a/earth.png');
170171
}
171172

dev/tests/integration/testsuite/Magento/Quote/Model/Quote/AddressTest.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Quote\Model\Quote;
77

8+
use Magento\Store\Api\StoreRepositoryInterface;
89
use Magento\TestFramework\Helper\Bootstrap;
910

1011
/**
@@ -25,6 +26,9 @@ class AddressTest extends \PHPUnit\Framework\TestCase
2526
/**@var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
2627
protected $customerRepository;
2728

29+
/** @var StoreRepositoryInterface */
30+
private $storeRepository;
31+
2832
/**
2933
* Initialize quote and customer fixtures
3034
*/
@@ -48,6 +52,8 @@ public function setUp()
4852
$this->_address->setId(1);
4953
$this->_address->load($this->_address->getId());
5054
$this->_address->setQuote($this->_quote);
55+
$this->storeRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
56+
->create(StoreRepositoryInterface::class);
5157
}
5258

5359
protected function tearDown()
@@ -309,4 +315,50 @@ public function dataProvider()
309315
[[123, true], [123, true]]
310316
];
311317
}
318+
319+
/**
320+
* Tests different shipping rates for different stores.
321+
*
322+
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
323+
* @magentoDataFixture Magento/Sales/_files/quote_with_customer.php
324+
* @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
325+
* @magentoDataFixture Magento/Sales/_files/quote.php
326+
* @magentoConfigFixture default_store carriers/flatrate/price 5
327+
* @magentoConfigFixture fixture_second_store_store carriers/flatrate/price 10
328+
* @magentoAppIsolation enabled
329+
* @magentoDbIsolation enabled
330+
* @dataProvider requestShippingRatesDataProvider
331+
*/
332+
public function testRequestShippingRates($storeCode, $expectedRate)
333+
{
334+
$store = $this->storeRepository->get($storeCode);
335+
$this->_quote->setStoreId($store->getId());
336+
$this->_address->setItemQty(1);
337+
$this->_address->requestShippingRates();
338+
/**
339+
* @var \Magento\Quote\Model\ResourceModel\Quote\Address\Rate\Collection $shippingRatesCollection
340+
*/
341+
$shippingRatesCollection = $this->_address->getShippingRatesCollection();
342+
/**
343+
* @var \Magento\Quote\Model\Quote\Address\Rate[] $shippingRates
344+
*/
345+
$shippingRates = $shippingRatesCollection->getItems();
346+
self::assertEquals(
347+
$expectedRate,
348+
$shippingRates[0]->getPrice()
349+
);
350+
}
351+
352+
/**
353+
* Data provider for testRequestShippingRates.
354+
*
355+
* @return array
356+
*/
357+
public function requestShippingRatesDataProvider()
358+
{
359+
return [
360+
['default', 5],
361+
['fixture_second_store', 10],
362+
];
363+
}
312364
}

pub/errors/processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function process503()
215215
public function processReport()
216216
{
217217
$this->pageTitle = 'There has been an error processing your request';
218-
$this->_response->setHttpResponseCode(503);
218+
$this->_response->setHttpResponseCode(500);
219219

220220
$this->showErrorMsg = false;
221221
$this->showSentMsg = false;

0 commit comments

Comments
 (0)