Skip to content

Commit 2251b17

Browse files
author
Natalia Momotenko
committed
Merge remote-tracking branch 'origin/develop' into public-prs2
2 parents 0d8a990 + 9fbaad7 commit 2251b17

File tree

144 files changed

+3584
-633
lines changed

Some content is hidden

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

144 files changed

+3584
-633
lines changed

app/code/Magento/Braintree/Helper/Country.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
namespace Magento\Braintree\Helper;
77

88
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
9+
use Magento\Braintree\Model\Adminhtml\System\Config\Country as CountryConfig;
910

1011
/**
1112
* Class Country
1213
*/
1314
class Country
1415
{
1516
/**
16-
* @var \Magento\Directory\Model\ResourceModel\Country\CollectionFactory
17+
* @var CollectionFactory
1718
*/
1819
private $collectionFactory;
1920

2021
/**
21-
* @var \Magento\Braintree\Model\Adminhtml\System\Config\Country
22+
* @var CountryConfig
2223
*/
2324
private $countryConfig;
2425

@@ -28,13 +29,11 @@ class Country
2829
private $countries;
2930

3031
/**
31-
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory
32-
* @param \Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
32+
* @param CollectionFactory $factory
33+
* @param CountryConfig $countryConfig
3334
*/
34-
public function __construct(
35-
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $factory,
36-
\Magento\Braintree\Model\Adminhtml\System\Config\Country $countryConfig
37-
) {
35+
public function __construct(CollectionFactory $factory, CountryConfig $countryConfig)
36+
{
3837
$this->collectionFactory = $factory;
3938
$this->countryConfig = $countryConfig;
4039
}

app/code/Magento/Braintree/etc/di.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<argument name="code" xsi:type="const">Magento\Braintree\Model\Ui\PayPal\ConfigProvider::PAYPAL_CODE</argument>
2323
<argument name="infoBlockType" xsi:type="string">BraintreePayPalInfo</argument>
2424
<argument name="valueHandlerPool" xsi:type="object">BraintreePayPalValueHandlerPool</argument>
25+
<argument name="validatorPool" xsi:type="object">BraintreePayPalValidatorPool</argument>
2526
<argument name="commandPool" xsi:type="object">BraintreePayPalCommandPool</argument>
2627
</arguments>
2728
</virtualType>
@@ -474,7 +475,7 @@
474475
</arguments>
475476
</virtualType>
476477

477-
<!-- Value validators infrastructure -->
478+
<!-- Braintree validators infrastructure -->
478479
<virtualType name="BraintreeCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
479480
<arguments>
480481
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
@@ -487,6 +488,22 @@
487488
</argument>
488489
</arguments>
489490
</virtualType>
491+
<!-- Braintree validators infrastructure -->
492+
493+
<!-- Braintree PayPal validators -->
494+
<virtualType name="BraintreePayPalCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
495+
<arguments>
496+
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\PayPal\Config</argument>
497+
</arguments>
498+
</virtualType>
499+
<virtualType name="BraintreePayPalValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
500+
<arguments>
501+
<argument name="validators" xsi:type="array">
502+
<item name="country" xsi:type="string">BraintreePayPalCountryValidator</item>
503+
</argument>
504+
</arguments>
505+
</virtualType>
506+
<!-- END Braintree PayPal validators -->
490507

491508
<type name="Magento\Braintree\Block\Info">
492509
<arguments>

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,19 @@ define([
1212
'Magento_Checkout/js/model/quote',
1313
'Magento_Checkout/js/model/full-screen-loader',
1414
'Magento_Checkout/js/model/payment/additional-validators',
15-
'Magento_Vault/js/view/payment/vault-enabler'
16-
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators, VaultEnabler) {
15+
'Magento_Vault/js/view/payment/vault-enabler',
16+
'Magento_Checkout/js/action/create-billing-address'
17+
], function (
18+
$,
19+
_,
20+
Component,
21+
Braintree,
22+
quote,
23+
fullScreenLoader,
24+
additionalValidators,
25+
VaultEnabler,
26+
createBillingAddress
27+
) {
1728
'use strict';
1829

1930
return Component.extend({
@@ -172,14 +183,16 @@ define([
172183
var billingAddress = {
173184
street: [address.streetAddress],
174185
city: address.locality,
175-
regionCode: address.region,
176186
postcode: address.postalCode,
177187
countryId: address.countryCodeAlpha2,
188+
email: customer.email,
178189
firstname: customer.firstName,
179190
lastname: customer.lastName,
180191
telephone: customer.phone
181192
};
182193

194+
billingAddress['region_code'] = address.region;
195+
billingAddress = createBillingAddress(billingAddress);
183196
quote.billingAddress(billingAddress);
184197
},
185198

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
<input type="checkbox"
110110
name="vault[is_enabled]"
111111
class="checkbox"
112-
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
113-
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
112+
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
113+
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
114114
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
115115
</label>
116116
<div class="field-tooltip toggle">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<input type="checkbox"
3333
name="vault[is_enabled]"
3434
class="checkbox"
35-
data-bind="attr: {'id': getCode() + '_vault_enabler'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
36-
<label class="label" data-bind="attr: {'for': getCode() + '_vault_enabler'}">
35+
data-bind="attr: {'id': getCode() + '_enable_vault'}, checked: vaultEnabler.isActivePaymentTokenEnabler"/>
36+
<label class="label" data-bind="attr: {'for': getCode() + '_enable_vault'}">
3737
<span><!-- ko i18n: 'Save for later use.'--><!-- /ko --></span>
3838
</label>
3939
<div class="field-tooltip toggle">

app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ private function getShipmentTypeValue($type)
331331
protected function cleanNotBundleAdditionalAttributes($dataRow)
332332
{
333333
if (!empty($dataRow['additional_attributes'])) {
334-
$additionalAttributes = explode(
335-
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
336-
$dataRow['additional_attributes']
337-
);
334+
$additionalAttributes = $this->parseAdditionalAttributes($dataRow['additional_attributes']);
338335
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
339336
}
340337

@@ -349,17 +346,38 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
349346
*/
350347
protected function getNotBundleAttributes($additionalAttributes)
351348
{
352-
$cleanedAdditionalAttributes = '';
353-
foreach ($additionalAttributes as $attribute) {
354-
list($attributeCode, $attributeValue) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attribute);
355-
if (!in_array('bundle_' . $attributeCode, $this->getBundleColumns())) {
356-
$cleanedAdditionalAttributes .= $attributeCode
357-
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
358-
. $attributeValue
359-
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
349+
$filteredAttributes = [];
350+
foreach ($additionalAttributes as $code => $value) {
351+
if (!in_array('bundle_' . $code, $this->getBundleColumns())) {
352+
$filteredAttributes[] = $code . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
360353
}
361354
}
355+
return implode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $filteredAttributes);
356+
}
362357

363-
return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
358+
/**
359+
* Retrieves additional attributes as array code=>value.
360+
*
361+
* @param string $additionalAttributes
362+
* @return array
363+
*/
364+
private function parseAdditionalAttributes($additionalAttributes)
365+
{
366+
$attributeNameValuePairs = explode(ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
367+
$preparedAttributes = [];
368+
$code = '';
369+
foreach ($attributeNameValuePairs as $attributeData) {
370+
//process case when attribute has ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR inside its value
371+
if (strpos($attributeData, ImportProductModel::PAIR_NAME_VALUE_SEPARATOR) === false) {
372+
if (!$code) {
373+
continue;
374+
}
375+
$preparedAttributes[$code] .= ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . $attributeData;
376+
continue;
377+
}
378+
list($code, $value) = explode(ImportProductModel::PAIR_NAME_VALUE_SEPARATOR, $attributeData, 2);
379+
$preparedAttributes[$code] = $value;
380+
}
381+
return $preparedAttributes;
364382
}
365383
}

app/code/Magento/BundleImportExport/Test/Unit/Model/Export/Product/RowCustomizerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,16 @@ public function testAddHeaderColumns()
178178
public function testAddData()
179179
{
180180
$preparedData = $this->rowCustomizerMock->prepareData($this->productResourceCollection, [1]);
181-
$attributes = 'attribute=1,sku_type=1,price_type=1,price_view=1,weight_type=1,values=values,shipment_type=1';
181+
$attributes = 'attribute=1,sku_type=1,attribute2="Text",price_type=1,price_view=1,weight_type=1,'
182+
. 'values=values,shipment_type=1,attribute3=One,Two,Three';
182183
$dataRow = [
183184
'sku' => 'sku1',
184185
'additional_attributes' => $attributes
185186
];
186187
$preparedRow = $preparedData->addData($dataRow, 1);
187188
$expected = [
188189
'sku' => 'sku1',
189-
'additional_attributes' => 'attribute=1',
190+
'additional_attributes' => 'attribute=1,attribute2="Text",attribute3=One,Two,Three',
190191
'bundle_price_type' => 'fixed',
191192
'bundle_shipment_type' => 'separately',
192193
'bundle_sku_type' => 'fixed',

app/code/Magento/CacheInvalidate/Observer/InvalidateVarnishObserver.php

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\CacheInvalidate\Observer;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\Event\ObserverInterface;
910

1011
class InvalidateVarnishObserver implements ObserverInterface
@@ -21,6 +22,13 @@ class InvalidateVarnishObserver implements ObserverInterface
2122
*/
2223
protected $purgeCache;
2324

25+
/**
26+
* Invalidation tags resolver
27+
*
28+
* @var \Magento\Framework\App\Cache\Tag\Resolver
29+
*/
30+
private $tagResolver;
31+
2432
/**
2533
* @param \Magento\PageCache\Model\Config $config
2634
* @param \Magento\CacheInvalidate\Model\PurgeCache $purgeCache
@@ -42,18 +50,35 @@ public function __construct(
4250
*/
4351
public function execute(\Magento\Framework\Event\Observer $observer)
4452
{
53+
$object = $observer->getEvent()->getObject();
54+
if (!is_object($object)) {
55+
return;
56+
}
4557
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled()) {
46-
$object = $observer->getEvent()->getObject();
47-
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
48-
$tags = [];
49-
$pattern = "((^|,)%s(,|$))";
50-
foreach ($object->getIdentities() as $tag) {
51-
$tags[] = sprintf($pattern, $tag);
52-
}
53-
if (!empty($tags)) {
54-
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
55-
}
58+
$bareTags = $this->getTagResolver()->getTags($object);
59+
60+
$tags = [];
61+
$pattern = "((^|,)%s(,|$))";
62+
foreach ($bareTags as $tag) {
63+
$tags[] = sprintf($pattern, $tag);
64+
}
65+
if (!empty($tags)) {
66+
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
5667
}
68+
69+
}
70+
}
71+
72+
/**
73+
* @deprecated
74+
* @return \Magento\Framework\App\Cache\Tag\Resolver
75+
*/
76+
private function getTagResolver()
77+
{
78+
if ($this->tagResolver === null) {
79+
$this->tagResolver = \Magento\Framework\App\ObjectManager::getInstance()
80+
->get(\Magento\Framework\App\Cache\Tag\Resolver::class);
5781
}
82+
return $this->tagResolver;
5883
}
5984
}

app/code/Magento/CacheInvalidate/Test/Unit/Observer/InvalidateVarnishObserverTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\CacheInvalidate\Test\Unit\Observer;
77

8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
9+
810
class InvalidateVarnishObserverTest extends \PHPUnit_Framework_TestCase
911
{
1012
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\CacheInvalidate\Observer\InvalidateVarnishObserver */
@@ -22,11 +24,16 @@ class InvalidateVarnishObserverTest extends \PHPUnit_Framework_TestCase
2224
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\DataObject\ */
2325
protected $observerObject;
2426

27+
/** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Cache\Tag\Resolver */
28+
private $tagResolver;
29+
2530
/**
2631
* Set up all mocks and data for test
2732
*/
2833
protected function setUp()
2934
{
35+
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
36+
3037
$this->configMock = $this->getMock(
3138
\Magento\PageCache\Model\Config::class,
3239
['getType', 'isEnabled'],
@@ -39,6 +46,10 @@ protected function setUp()
3946
$this->configMock,
4047
$this->purgeCache
4148
);
49+
50+
$this->tagResolver = $this->getMock(\Magento\Framework\App\Cache\Tag\Resolver::class, [], [], '', false);
51+
$helper->setBackwardCompatibleProperty($this->model, 'tagResolver', $this->tagResolver);
52+
4253
$this->observerMock = $this->getMock(
4354
\Magento\Framework\Event\Observer::class,
4455
['getEvent'],
@@ -65,10 +76,12 @@ public function testInvalidateVarnish()
6576
)->will(
6677
$this->returnValue(\Magento\PageCache\Model\Config::VARNISH)
6778
);
79+
6880
$eventMock = $this->getMock(\Magento\Framework\Event::class, ['getObject'], [], '', false);
6981
$eventMock->expects($this->once())->method('getObject')->will($this->returnValue($this->observerObject));
7082
$this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
71-
$this->observerObject->expects($this->once())->method('getIdentities')->will($this->returnValue($tags));
83+
$this->tagResolver->expects($this->once())->method('getTags')->with($this->observerObject)
84+
->will($this->returnValue($tags));
7285
$this->purgeCache->expects($this->once())->method('sendPurgeRequest')->with($pattern);
7386

7487
$this->model->execute($this->observerMock);

app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ public function execute()
9999
return $this->ajaxRequestResponse($category, $resultPage);
100100
}
101101

102+
$resultPageTitle = $categoryId ? $category->getName() . ' (ID: ' . $categoryId . ')' : __('Categories');
102103
$resultPage->setActiveMenu('Magento_Catalog::catalog_categories');
103104
$resultPage->getConfig()->getTitle()->prepend(__('Categories'));
104-
$resultPage->getConfig()->getTitle()->prepend($categoryId ? $category->getName() : __('Categories'));
105+
$resultPage->getConfig()->getTitle()->prepend($resultPageTitle);
105106
$resultPage->addBreadcrumb(__('Manage Catalog Categories'), __('Manage Categories'));
106107

107108
$block = $resultPage->getLayout()->getBlock('catalog.wysiwyg.js');

0 commit comments

Comments
 (0)