Skip to content

Commit 4bb14cc

Browse files
author
Oleksandr Manchenko
committed
Merge branch 'develop' of https://github.corp.ebay.com/magento-qmt/magento2ce into MTA-2343
Conflicts: dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php
2 parents 20506ef + 4fd68c3 commit 4bb14cc

File tree

181 files changed

+9155
-2484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+9155
-2484
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Captcha\Test\Unit\Model\Cart;
7+
8+
class ConfigPluginTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var \Magento\Captcha\Model\Cart\ConfigPlugin
12+
*/
13+
protected $model;
14+
15+
/**
16+
* @var \PHPUnit_Framework_MockObject_MockObject
17+
*/
18+
protected $configProviderMock;
19+
20+
public function setUp()
21+
{
22+
$this->configProviderMock = $this->getMock('\Magento\Captcha\Model\Checkout\ConfigProvider', [], [], '', false);
23+
$this->model = new \Magento\Captcha\Model\Cart\ConfigPlugin(
24+
$this->configProviderMock
25+
);
26+
}
27+
28+
public function testAfterGetConfig()
29+
{
30+
$resultMock = [
31+
'result' => [
32+
'data' => 'resultDataMock'
33+
]
34+
];
35+
$configMock = [
36+
'config' => [
37+
'data' => 'configDataMock'
38+
]
39+
];
40+
$expectedResult = array_merge_recursive($resultMock, $configMock);
41+
$sidebarMock = $this->getMock('\Magento\Checkout\Block\Cart\Sidebar', [], [], '', false);
42+
$this->configProviderMock->expects($this->once())->method('getConfig')->willReturn($configMock);
43+
44+
$this->assertEquals($expectedResult, $this->model->afterGetConfig($sidebarMock, $resultMock));
45+
}
46+
}

app/code/Magento/Catalog/Helper/Product/Compare.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ public function getAddToCartUrl($product)
203203
$beforeCompareUrl = $this->_catalogSession->getBeforeCompareUrl();
204204
$params = [
205205
'product' => $product->getId(),
206-
\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl)
206+
\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl),
207+
'_secure' => $this->_getRequest()->isSecure()
207208
];
208209

209210
return $this->_getUrl('checkout/cart/add', $params);

app/code/Magento/Catalog/Test/Unit/Helper/Product/CompareTest.php

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Catalog\Test\Unit\Helper\Product;
88

9+
use Magento\Framework\App\Action\Action;
10+
911
/**
1012
* Class CompareTest
1113
*/
@@ -41,12 +43,17 @@ class CompareTest extends \PHPUnit_Framework_TestCase
4143
*/
4244
protected $urlEncoder;
4345

46+
/**
47+
* @var \Magento\Catalog\Model\Session | \PHPUnit_Framework_MockObject_MockObject
48+
*/
49+
protected $catalogSessionMock;
50+
4451
public function setUp()
4552
{
4653
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
4754

4855
$this->urlBuilder = $this->getMock('Magento\Framework\Url', ['getUrl'], [], '', false);
49-
$this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getServer'], [], '', false);
56+
$this->request = $this->getMock('Magento\Framework\App\Request\Http', ['getServer', 'isSecure'], [], '', false);
5057
/** @var \Magento\Framework\App\Helper\Context $context */
5158
$this->context = $this->getMock(
5259
'Magento\Framework\App\Helper\Context',
@@ -58,7 +65,9 @@ public function setUp()
5865
$this->urlEncoder = $this->getMockBuilder('Magento\Framework\Url\EncoderInterface')->getMock();
5966
$this->urlEncoder->expects($this->any())
6067
->method('encode')
61-
->will($this->returnArgument(0));
68+
->willReturnCallback(function ($url) {
69+
return strtr(base64_encode($url), '+/=', '-_,');
70+
});
6271
$this->context->expects($this->once())
6372
->method('getUrlBuilder')
6473
->will($this->returnValue($this->urlBuilder));
@@ -75,10 +84,21 @@ public function setUp()
7584
'',
7685
false
7786
);
87+
$this->catalogSessionMock = $this->getMock(
88+
'\Magento\Catalog\Model\Session',
89+
['getBeforeCompareUrl'],
90+
[],
91+
'',
92+
false
93+
);
7894

7995
$this->compareHelper = $objectManager->getObject(
8096
'Magento\Catalog\Helper\Product\Compare',
81-
['context' => $this->context, 'postHelper' => $this->postDataHelper]
97+
[
98+
'context' => $this->context,
99+
'postHelper' => $this->postDataHelper,
100+
'catalogSession' => $this->catalogSessionMock
101+
]
82102
);
83103
}
84104

@@ -89,7 +109,7 @@ public function testGetPostDataRemove()
89109
$removeUrl = 'catalog/product_compare/remove';
90110
$compareListUrl = 'catalog/product_compare';
91111
$postParams = [
92-
\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $compareListUrl,
112+
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($compareListUrl), '+/=', '-_,'),
93113
'product' => $productId
94114
];
95115

@@ -136,7 +156,7 @@ public function testGetPostDataClearList()
136156
$refererUrl = 'home/';
137157
$clearUrl = 'catalog/product_compare/clear';
138158
$postParams = [
139-
\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED => $refererUrl
159+
Action::PARAM_NAME_URL_ENCODED => strtr(base64_encode($refererUrl), '+/=', '-_,')
140160
];
141161

142162
//Verification
@@ -157,4 +177,27 @@ public function testGetPostDataClearList()
157177

158178
$this->assertTrue($this->compareHelper->getPostDataClearList());
159179
}
180+
181+
public function testGetAddToCartUrl()
182+
{
183+
$productId = 42;
184+
$isRequestSecure = false;
185+
$beforeCompareUrl = 'http://magento.com/compare/before';
186+
$encodedCompareUrl = strtr(base64_encode($beforeCompareUrl), '+/=', '-_,');
187+
$expectedResult = [
188+
'product' => $productId,
189+
Action::PARAM_NAME_URL_ENCODED => $encodedCompareUrl,
190+
'_secure' => $isRequestSecure
191+
];
192+
193+
$productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);
194+
$this->catalogSessionMock->expects($this->once())->method('getBeforeCompareUrl')->willReturn($beforeCompareUrl);
195+
$productMock->expects($this->once())->method('getId')->willReturn($productId);
196+
$this->urlEncoder->expects($this->once())->method('encode')->with($beforeCompareUrl)
197+
->willReturn($encodedCompareUrl);
198+
$this->request->expects($this->once())->method('isSecure')->willReturn($isRequestSecure);
199+
200+
$this->urlBuilder->expects($this->once())->method('getUrl')->with('checkout/cart/add', $expectedResult);
201+
$this->compareHelper->getAddToCartUrl($productMock);
202+
}
160203
}

app/code/Magento/Checkout/Block/Checkout/TotalsProcessor.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ public function __construct(
3131
public function process($jsLayout)
3232
{
3333
$configData = $this->scopeConfig->getValue('sales/totals_sort');
34-
$totals = $jsLayout['components']['checkout']['children']['summary']['children']['totals']['children'];
34+
$totals = $jsLayout['components']['checkout']['children']['sidebar']['children']['summary']
35+
['children']['totals']['children'];
3536
foreach ($totals as $code => &$total) {
3637
//convert JS naming style to config naming style
3738
$code = str_replace('-', '_', $code);
3839
if (array_key_exists($code, $configData)) {
3940
$total['sortOrder'] = $configData[$code];
4041
}
4142
}
42-
$jsLayout['components']['checkout']['children']['summary']['children']['totals']['children'] = $totals;
43+
$jsLayout['components']['checkout']['children']['sidebar']['children']['summary']
44+
['children']['totals']['children'] = $totals;
4345

44-
return array_merge_recursive($jsLayout, $totals);
46+
return $jsLayout;
4547
}
4648
}

app/code/Magento/Checkout/Controller/Index/Index.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ class Index extends \Magento\Checkout\Controller\Onepage
1515
*/
1616
public function execute()
1717
{
18+
/** @var \Magento\Checkout\Helper\Data $checkoutHelper */
1819
$checkoutHelper = $this->_objectManager->get('Magento\Checkout\Helper\Data');
1920
if (!$checkoutHelper->canOnepageCheckout()) {
2021
$this->messageManager->addError(__('One-page checkout is turned off.'));
2122
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
2223
}
2324

2425
$quote = $this->getOnepage()->getQuote();
25-
26-
if (!$this->_customerSession->isLoggedIn() && !$checkoutHelper->isAllowedGuestCheckout($quote)) {
27-
$this->messageManager->addError(__('Guest checkout is disabled.'));
26+
if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
2827
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
2928
}
3029

31-
if (!$quote->hasItems() || $quote->getHasError() || !$quote->validateMinimumAmount()) {
30+
if (!$this->_customerSession->isLoggedIn() && !$checkoutHelper->isAllowedGuestCheckout($quote)) {
31+
$this->messageManager->addError(__('Guest checkout is disabled.'));
3232
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
3333
}
3434

app/code/Magento/Checkout/Helper/Cart.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ public function getAddUrl($product, $additional = [])
7777
$continueUrl = $this->urlEncoder->encode($this->_urlBuilder->getCurrentUrl());
7878
$urlParamName = \Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED;
7979

80-
$routeParams = [$urlParamName => $continueUrl, 'product' => $product->getEntityId()];
80+
$routeParams = [
81+
$urlParamName => $continueUrl,
82+
'product' => $product->getEntityId(),
83+
'_secure' => $this->_getRequest()->isSecure()
84+
];
8185

8286
if (!empty($additional)) {
8387
$routeParams = array_merge($routeParams, $additional);

app/code/Magento/Checkout/Model/ShippingInformationManagement.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public function saveAddressInformation(
109109
$this->validateQuote($quote);
110110

111111
$saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0;
112-
$sameAsBilling = $address->getSameAsBilling() ? 1 : 0;
113112
$customerAddressId = $address->getCustomerAddressId();
114113
$this->addressValidator->validate($address);
115114
$quote->setShippingAddress($address);
@@ -119,7 +118,7 @@ public function saveAddressInformation(
119118
$addressData = $this->addressRepository->getById($customerAddressId);
120119
$address = $quote->getShippingAddress()->importCustomerAddressData($addressData);
121120
}
122-
$address->setSameAsBilling($sameAsBilling);
121+
123122
$address->setSaveInAddressBook($saveInAddressBook);
124123
$address->setCollectShippingRates(true);
125124

0 commit comments

Comments
 (0)