Skip to content

Commit 267e336

Browse files
Merge branch 'develop' of github.com:magento-folks/magento2ce into bugfix
2 parents 33f6c0a + 1a9a75f commit 267e336

File tree

67 files changed

+1564
-212
lines changed

Some content is hidden

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

67 files changed

+1564
-212
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ addons:
77
- mysql-client-core-5.6
88
- mysql-client-5.6
99
- postfix
10+
firefox: "46.0"
11+
hosts:
12+
- magento2.travis
1013
language: php
1114
php:
1215
- 7.0
@@ -16,19 +19,26 @@ env:
1619
- COMPOSER_BIN_DIR=~/bin
1720
- INTEGRATION_SETS=3
1821
- NODE_JS_VERSION=6
22+
- MAGENTO_HOST_NAME="magento2.travis"
1923
matrix:
2024
- TEST_SUITE=unit
2125
- TEST_SUITE=integration INTEGRATION_INDEX=1
2226
- TEST_SUITE=integration INTEGRATION_INDEX=2
2327
- TEST_SUITE=integration INTEGRATION_INDEX=3
2428
- TEST_SUITE=static
2529
- TEST_SUITE=js
30+
- TEST_SUITE=functional ACCEPTANCE_INDEX=1
31+
- TEST_SUITE=functional ACCEPTANCE_INDEX=2
2632
matrix:
2733
exclude:
2834
- php: 7.0
2935
env: TEST_SUITE=static
3036
- php: 7.0
3137
env: TEST_SUITE=js
38+
- php: 7.0
39+
env: TEST_SUITE=functional ACCEPTANCE_INDEX=1
40+
- php: 7.0
41+
env: TEST_SUITE=functional ACCEPTANCE_INDEX=2
3242
cache:
3343
apt: true
3444
directories:

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ define(
3636
braintreeDeviceData: null,
3737
paymentMethodNonce: null,
3838
lastBillingAddress: null,
39+
ccCode: null,
40+
ccMessageContainer: null,
3941
validatorManager: validatorManager,
4042
code: 'braintree',
4143

@@ -138,9 +140,39 @@ define(
138140
return;
139141
}
140142

143+
this.restoreMessageContainer();
144+
this.restoreCode();
145+
146+
/**
147+
* Define onReady callback
148+
*/
149+
braintree.onReady = function () {};
141150
this.initBraintree();
142151
},
143152

153+
/**
154+
* Restore original message container for cc-form component
155+
*/
156+
restoreMessageContainer: function () {
157+
this.messageContainer = this.ccMessageContainer;
158+
},
159+
160+
/**
161+
* Restore original code for cc-form component
162+
*/
163+
restoreCode: function () {
164+
this.code = this.ccCode;
165+
},
166+
167+
/** @inheritdoc */
168+
initChildren: function () {
169+
this._super();
170+
this.ccMessageContainer = this.messageContainer;
171+
this.ccCode = this.code;
172+
173+
return this;
174+
},
175+
144176
/**
145177
* Init config
146178
*/

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/vault.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ define([
5252
var self = this;
5353

5454
/**
55-
* Define already callback
55+
* Define onReady callback
5656
*/
5757
Braintree.onReady = function () {
5858
self.getPaymentMethodNonce();
@@ -78,6 +78,7 @@ define([
7878
formComponent.setPaymentMethodNonce(response.paymentMethodNonce);
7979
formComponent.additionalData['public_hash'] = self.publicHash;
8080
formComponent.code = self.code;
81+
formComponent.messageContainer = self.messageContainer;
8182
formComponent.placeOrder();
8283
});
8384
})

app/code/Magento/Braintree/view/frontend/web/template/payment/form.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@
139139
<button class="action primary checkout"
140140
type="submit"
141141
data-bind="
142-
click: placeOrderClick,
143-
attr: {title: $t('Place Order')}
144-
">
142+
click: placeOrderClick,
143+
attr: {title: $t('Place Order')},
144+
css: {disabled: !isPlaceOrderActionAllowed()},
145+
enable: isActive()
146+
"
147+
disabled>
145148
<span data-bind="i18n: 'Place Order'"></span>
146149
</button>
147150
</div>

app/code/Magento/Bundle/Model/Product/SaveHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public function execute($entity, $arguments = [])
6666
$options = $bundleProductOptions ?: [];
6767
foreach ($options as $option) {
6868
$this->optionRepository->save($entity, $option);
69-
$entity->setCopyFromView(false);
7069
}
70+
$entity->setCopyFromView(false);
7171
}
7272
return $entity;
7373
}

app/code/Magento/Cms/Block/Page.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,26 @@ protected function _prepareLayout()
126126
*/
127127
protected function _addBreadcrumbs(\Magento\Cms\Model\Page $page)
128128
{
129+
$homePageIdentifier = $this->_scopeConfig->getValue(
130+
'web/default/cms_home_page',
131+
ScopeInterface::SCOPE_STORE
132+
);
133+
$homePageDelimiterPosition = strrpos($homePageIdentifier, '|');
134+
if ($homePageDelimiterPosition) {
135+
$homePageIdentifier = substr($homePageIdentifier, 0, $homePageDelimiterPosition);
136+
}
137+
$noRouteIdentifier = $this->_scopeConfig->getValue(
138+
'web/default/cms_no_route',
139+
ScopeInterface::SCOPE_STORE
140+
);
141+
$noRouteDelimiterPosition = strrpos($noRouteIdentifier, '|');
142+
if ($noRouteDelimiterPosition) {
143+
$noRouteIdentifier = substr($noRouteIdentifier, 0, $noRouteDelimiterPosition);
144+
}
129145
if ($this->_scopeConfig->getValue('web/default/show_cms_breadcrumbs', ScopeInterface::SCOPE_STORE)
130146
&& ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'))
131-
&& $page->getIdentifier() !== $this->_scopeConfig->getValue(
132-
'web/default/cms_home_page',
133-
ScopeInterface::SCOPE_STORE
134-
)
135-
&& $page->getIdentifier() !== $this->_scopeConfig->getValue(
136-
'web/default/cms_no_route',
137-
ScopeInterface::SCOPE_STORE
138-
)
147+
&& $page->getIdentifier() !== $homePageIdentifier
148+
&& $page->getIdentifier() !== $noRouteIdentifier
139149
) {
140150
$breadcrumbsBlock->addCrumb(
141151
'home',

app/code/Magento/Cookie/Helper/Cookie.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,22 @@ public function __construct(
7070
public function isUserNotAllowSaveCookie()
7171
{
7272
$acceptedSaveCookiesWebsites = $this->_getAcceptedSaveCookiesWebsites();
73+
return $this->isCookieRestrictionModeEnabled() &&
74+
empty($acceptedSaveCookiesWebsites[$this->_website->getId()]);
75+
}
76+
77+
/**
78+
* Check if cookie restriction mode is enabled for this store
79+
*
80+
* @return bool
81+
*/
82+
public function isCookieRestrictionModeEnabled()
83+
{
7384
return $this->scopeConfig->getValue(
7485
self::XML_PATH_COOKIE_RESTRICTION,
7586
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
7687
$this->_currentStore
77-
) && empty($acceptedSaveCookiesWebsites[$this->_website->getId()]);
88+
);
7889
}
7990

8091
/**

app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/** @var \Magento\Cookie\Block\Html\Notices $block */
1010
?>
11-
<?php if ($this->helper(\Magento\Cookie\Helper\Cookie::class)->isUserNotAllowSaveCookie()): ?>
11+
<?php if ($this->helper(\Magento\Cookie\Helper\Cookie::class)->isCookieRestrictionModeEnabled()): ?>
1212
<div role="alertdialog"
1313
tabindex="-1"
1414
class="message global cookie"

app/code/Magento/Cookie/view/frontend/web/js/notices.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
$(this.options.cookieAllowButtonSelector).on('click', $.proxy(function () {
2525
var cookieExpires = new Date(new Date().getTime() + this.options.cookieLifetime * 1000);
2626

27-
$.mage.cookies.set(this.options.cookieName, this.options.cookieValue, {
27+
$.mage.cookies.set(this.options.cookieName, JSON.stringify(this.options.cookieValue), {
2828
expires: cookieExpires
2929
});
3030

app/code/Magento/Msrp/view/base/templates/product/price/msrp.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if ($product->isSaleable()) {
5656
$data = ['addToCart' => [
5757
'origin'=> 'msrp',
5858
'popupId' => '#' . $popupId,
59-
'productName' => $product->getName(),
59+
'productName' => $block->escapeJs($block->escapeHtml($product->getName())),
6060
'productId' => $productId,
6161
'productIdInput' => 'input[type="hidden"][name="product"]',
6262
'realPrice' => $block->getRealPriceHtml(),
@@ -80,7 +80,7 @@ if ($product->isSaleable()) {
8080
<a href="javascript:void(0);"
8181
id="<?php /* @escapeNotVerified */ echo($popupId);?>"
8282
class="action map-show-info"
83-
data-mage-init='<?= /* @escapeNotVerified */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($data)?>'><?php /* @escapeNotVerified */ echo __('Click for price'); ?>
83+
data-mage-init='<?= /* @noEscape */ $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($data)?>'><?php /* @escapeNotVerified */ echo __('Click for price'); ?>
8484
</a>
8585
<?php else: ?>
8686
<span class="msrp-message">

app/code/Magento/Msrp/view/frontend/templates/render/item/price_msrp_item.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<a href="javascript:void(0);"
3939
id="<?php /* @escapeNotVerified */ echo($popupId);?>"
4040
data-mage-init='{"addToCart":{"popupId": "#<?php /* @escapeNotVerified */ echo($popupId);?>",
41-
"productName": "<?php /* @escapeNotVerified */ echo $_product->getName() ?>",
41+
"productName": "<?php /* @noEscape */ echo $block->escapeJs($block->escapeHtml($_product->getName())) ?>",
4242
"realPrice": <?php /* @escapeNotVerified */ echo $block->getRealPriceJs($_product) ?>,
4343
"msrpPrice": "<?php /* @escapeNotVerified */ echo $_msrpPrice ?>",
4444
"priceElementId":"<?php /* @escapeNotVerified */ echo $priceElementId ?>",
@@ -51,5 +51,5 @@
5151
</span>
5252
<?php endif; ?>
5353
<?php $helpLinkId = 'msrp-help-' . $_id . $block->getRandomString(20); ?>
54-
<a href="javascript:void(0);" id="<?php /* @escapeNotVerified */ echo($helpLinkId);?>" data-mage-init='{"addToCart":{"helpLinkId": "#<?php /* @escapeNotVerified */ echo($helpLinkId);?>", "productName": "<?php /* @escapeNotVerified */ echo $_product->getName() ?>"}}' class="link tip"><?php /* @escapeNotVerified */ echo __("What's this?"); ?></a>
54+
<a href="javascript:void(0);" id="<?php /* @escapeNotVerified */ echo($helpLinkId);?>" data-mage-init='{"addToCart":{"helpLinkId": "#<?php /* @escapeNotVerified */ echo($helpLinkId);?>", "productName": "<?php /* @noEscape */ echo $block->escapeJs($block->escapeHtml($_product->getName())) ?>"}}' class="link tip"><?php /* @escapeNotVerified */ echo __("What's this?"); ?></a>
5555
</div>

app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Magento\Framework\App\ObjectManager;
16+
use Magento\Directory\Model\AllowedCountries;
1617

1718
/**
1819
* Multishipping checkout model
@@ -146,12 +147,19 @@ class Multishipping extends \Magento\Framework\DataObject
146147
*/
147148
private $cartExtensionFactory;
148149

150+
/**
151+
* @var AllowedCountries
152+
*/
153+
private $allowedCountryReader;
154+
149155
/**
150156
* @var \Magento\Quote\Model\Quote\ShippingAssignment\ShippingAssignmentProcessor
151157
*/
152158
private $shippingAssignmentProcessor;
153159

154160
/**
161+
* Multishipping constructor.
162+
*
155163
* @param \Magento\Checkout\Model\Session $checkoutSession
156164
* @param \Magento\Customer\Model\Session $customerSession
157165
* @param \Magento\Sales\Model\OrderFactory $orderFactory
@@ -174,6 +182,7 @@ class Multishipping extends \Magento\Framework\DataObject
174182
* @param \Magento\Framework\Api\FilterBuilder $filterBuilder
175183
* @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
176184
* @param array $data
185+
* @param AllowedCountries|null $allowedCountryReader
177186
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
178187
*/
179188
public function __construct(
@@ -198,7 +207,8 @@ public function __construct(
198207
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
199208
\Magento\Framework\Api\FilterBuilder $filterBuilder,
200209
\Magento\Quote\Model\Quote\TotalsCollector $totalsCollector,
201-
array $data = []
210+
array $data = [],
211+
AllowedCountries $allowedCountryReader = null
202212
) {
203213
$this->_eventManager = $eventManager;
204214
$this->_scopeConfig = $scopeConfig;
@@ -221,6 +231,8 @@ public function __construct(
221231
$this->quotePaymentToOrderPayment = $quotePaymentToOrderPayment;
222232
$this->quoteAddressToOrderAddress = $quoteAddressToOrderAddress;
223233
$this->totalsCollector = $totalsCollector;
234+
$this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance()
235+
->get(AllowedCountries::class);
224236
parent::__construct($data);
225237
$this->_init();
226238
}
@@ -696,6 +708,18 @@ protected function _validate()
696708
__('Please specify shipping methods for all addresses.')
697709
);
698710
}
711+
712+
// Checks if a country id present in the allowed countries list.
713+
if (
714+
!in_array(
715+
$address->getCountryId(),
716+
$this->allowedCountryReader->getAllowedCountries()
717+
)
718+
) {
719+
throw new \Magento\Framework\Exception\LocalizedException(
720+
__('Some addresses cannot be used due to country-specific configurations.')
721+
);
722+
}
699723
}
700724
$addressValidation = $quote->getBillingAddress()->validate();
701725
if ($addressValidation !== true) {

app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
use Magento\Store\Model\StoreManagerInterface;
4545
use PHPUnit_Framework_MockObject_MockObject;
4646
use PHPUnit_Framework_TestCase;
47+
use Magento\Quote\Model\Quote\Payment;
48+
use Magento\Payment\Model\Method\AbstractMethod;
49+
use Magento\Directory\Model\AllowedCountries;
4750

4851
/**
4952
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -146,6 +149,13 @@ protected function setUp()
146149
$this->customerSessionMock->expects($this->atLeastOnce())->method('getCustomerDataObject')
147150
->willReturn($this->customerMock);
148151
$this->totalsCollectorMock = $this->createSimpleMock(TotalsCollector::class);
152+
$allowedCountryReaderMock = $this->getMockBuilder(AllowedCountries::class)
153+
->disableOriginalConstructor()
154+
->setMethods(['getAllowedCountries'])
155+
->getMock();
156+
$allowedCountryReaderMock->method('getAllowedCountries')
157+
->willReturn(['EN'=>'EN']);
158+
149159
$this->model = new Multishipping(
150160
$this->checkoutSessionMock,
151161
$this->customerSessionMock,
@@ -168,7 +178,8 @@ protected function setUp()
168178
$this->searchCriteriaBuilderMock,
169179
$this->filterBuilderMock,
170180
$this->totalsCollectorMock,
171-
$data
181+
$data,
182+
$allowedCountryReaderMock
172183
);
173184

174185
$this->cartExtensionFactoryMock = $this->getMockBuilder(CartExtensionFactory::class)
@@ -357,6 +368,49 @@ public function testSetShippingMethods()
357368
$this->model->setShippingMethods($methodsArray);
358369
}
359370

371+
/**
372+
* Tests exception for addresses with country id not in the allowed countries list.
373+
*
374+
* @expectedException \Magento\Framework\Exception\LocalizedException
375+
* @expectedExceptionMessage Some addresses cannot be used due to country-specific configurations.
376+
*/
377+
public function testCreateOrdersCountryNotPresentInAllowedListException()
378+
{
379+
$abstractMethod = $this->getMockBuilder(AbstractMethod::class)
380+
->disableOriginalConstructor()
381+
->setMethods(['isAvailable'])
382+
->getMockForAbstractClass();
383+
$abstractMethod->method('isAvailable')
384+
->willReturn(true);
385+
386+
$paymentMock = $this->getMockBuilder(Payment::class)
387+
->disableOriginalConstructor()
388+
->setMethods(['getMethodInstance'])
389+
->getMock();
390+
$paymentMock->method('getMethodInstance')
391+
->willReturn($abstractMethod);
392+
393+
$shippingAddressMock = $this->getMockBuilder(Address::class)
394+
->disableOriginalConstructor()
395+
->setMethods(['validate', 'getShippingMethod', 'getShippingRateByCode', 'getCountryId'])
396+
->getMock();
397+
$shippingAddressMock->method('validate')
398+
->willReturn(true);
399+
$shippingAddressMock->method('getShippingMethod')
400+
->willReturn('carrier');
401+
$shippingAddressMock->method('getShippingRateByCode')
402+
->willReturn('code');
403+
$shippingAddressMock->method('getCountryId')
404+
->willReturn('EU');
405+
406+
$this->quoteMock->method('getPayment')
407+
->willReturn($paymentMock);
408+
$this->quoteMock->method('getAllShippingAddresses')
409+
->willReturn([$shippingAddressMock]);
410+
411+
$this->model->createOrders();
412+
}
413+
360414
/**
361415
* @param ShippingAssignment $shippingAssignmentMock
362416
* @return CartExtension|PHPUnit_Framework_MockObject_MockObject

0 commit comments

Comments
 (0)