Skip to content

Commit e4a017d

Browse files
author
Robert He
committed
Merge branch '2.1-develop' into MAGETWO-58895-compare_products_2.1.x
2 parents d0b9463 + aeb9504 commit e4a017d

File tree

250 files changed

+9374
-2210
lines changed

Some content is hidden

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

250 files changed

+9374
-2210
lines changed

app/code/Magento/Backend/App/Config.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,66 @@
1010

1111
namespace Magento\Backend\App;
1212

13+
use Magento\Config\App\Config\Type\System;
1314
use Magento\Framework\App\Config\ScopeConfigInterface;
1415

1516
/**
16-
* Backend config accessor
17+
* Backend config accessor.
1718
*/
1819
class Config implements ConfigInterface
1920
{
2021
/**
21-
* @var \Magento\Framework\App\Config\ScopePool
22+
* @var \Magento\Framework\App\Config
2223
*/
23-
protected $_scopePool;
24+
protected $appConfig;
2425

2526
/**
26-
* @param \Magento\Framework\App\Config\ScopePool $scopePool
27+
* @var array
2728
*/
28-
public function __construct(\Magento\Framework\App\Config\ScopePool $scopePool)
29+
private $data;
30+
31+
/**
32+
* @param \Magento\Framework\App\Config $appConfig
33+
* @return void
34+
*/
35+
public function __construct(\Magento\Framework\App\Config $appConfig)
2936
{
30-
$this->_scopePool = $scopePool;
37+
$this->appConfig = $appConfig;
3138
}
3239

3340
/**
34-
* Retrieve config value by path and scope
35-
*
36-
* @param string $path
37-
* @return mixed
41+
* @inheritdoc
3842
*/
3943
public function getValue($path)
4044
{
41-
return $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
45+
if (isset($this->data[$path])) {
46+
return $this->data[$path];
47+
}
48+
49+
$configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
50+
if ($path) {
51+
$configPath .= '/' . $path;
52+
}
53+
return $this->appConfig->get(System::CONFIG_TYPE, $configPath);
4254
}
4355

4456
/**
45-
* Set config value in the corresponding config scope
46-
*
47-
* @param string $path
48-
* @param mixed $value
49-
* @return void
57+
* @inheritdoc
5058
*/
5159
public function setValue($path, $value)
5260
{
53-
$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->setValue($path, $value);
61+
$this->data[$path] = $value;
5462
}
5563

5664
/**
57-
* Retrieve config flag
58-
*
59-
* @param string $path
60-
* @return bool
65+
* @inheritdoc
6166
*/
6267
public function isSetFlag($path)
6368
{
64-
return !!$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
69+
$configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
70+
if ($path) {
71+
$configPath .= '/' . $path;
72+
}
73+
return (bool) $this->appConfig->get(System::CONFIG_TYPE, $configPath);
6574
}
6675
}

app/code/Magento/Backend/App/ConfigInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface ConfigInterface
1515
/**
1616
* Retrieve config value by path
1717
*
18+
* Path should looks like keys imploded by "/". For example scopes/stores/admin
19+
*
1820
* @param string $path
1921
* @return mixed
2022
* @api
@@ -24,6 +26,7 @@ public function getValue($path);
2426
/**
2527
* Set config value
2628
*
29+
* @deprecated
2730
* @param string $path
2831
* @param mixed $value
2932
* @return void
@@ -34,6 +37,8 @@ public function setValue($path, $value);
3437
/**
3538
* Retrieve config flag
3639
*
40+
* Path should looks like keys imploded by "/". For example scopes/stores/admin
41+
*
3742
* @param string $path
3843
* @return bool
3944
* @api

app/code/Magento/Backend/Test/Unit/App/ConfigTest.php

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77

88
use Magento\Backend\App\Config;
99

10+
/**
11+
* Test reading by path and reading flag from config
12+
*
13+
* @see \Magento\Backend\App\Config
14+
* @package Magento\Backend\Test\Unit\App
15+
*/
1016
class ConfigTest extends \PHPUnit_Framework_TestCase
1117
{
1218
/**
13-
* @var \Magento\Framework\App\Config\ScopePool|\PHPUnit_Framework_MockObject_MockObject
19+
* @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject
1420
*/
15-
protected $sectionPool;
21+
protected $appConfig;
1622

1723
/**
1824
* @var Config
@@ -21,102 +27,64 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
2127

2228
protected function setUp()
2329
{
24-
$this->sectionPool = $this->getMock(
25-
'Magento\Framework\App\Config\ScopePool',
26-
['getScope', 'clean'],
30+
$this->appConfig = $this->getMock(
31+
'Magento\Framework\App\Config',
32+
['get'],
2733
[],
2834
'',
2935
false
3036
);
31-
$this->model = new \Magento\Backend\App\Config($this->sectionPool);
37+
$this->model = new \Magento\Backend\App\Config($this->appConfig);
3238
}
3339

3440
public function testGetValue()
3541
{
3642
$expectedValue = 'some value';
3743
$path = 'some path';
38-
$configData = $this->getConfigDataMock('getValue');
39-
$configData->expects(
40-
$this->once()
41-
)->method(
42-
'getValue'
43-
)->with(
44-
$this->equalTo($path)
45-
)->will(
46-
$this->returnValue($expectedValue)
47-
);
48-
$this->sectionPool->expects(
44+
$this->appConfig->expects(
4945
$this->once()
5046
)->method(
51-
'getScope'
47+
'get'
5248
)->with(
53-
$this->equalTo('default'),
49+
$this->equalTo('system'),
50+
$this->equalTo('default/' . $path),
5451
$this->isNull()
5552
)->will(
56-
$this->returnValue($configData)
53+
$this->returnValue($expectedValue)
5754
);
5855
$this->assertEquals($expectedValue, $this->model->getValue($path));
5956
}
6057

61-
public function testSetValue()
62-
{
63-
$value = 'some value';
64-
$path = 'some path';
65-
$configData = $this->getConfigDataMock('setValue');
66-
$configData->expects($this->once())->method('setValue')->with($this->equalTo($path), $this->equalTo($value));
67-
$this->sectionPool->expects(
68-
$this->once()
69-
)->method(
70-
'getScope'
71-
)->with(
72-
$this->equalTo('default'),
73-
$this->isNull()
74-
)->will(
75-
$this->returnValue($configData)
76-
);
77-
$this->model->setValue($path, $value);
78-
}
79-
8058
/**
59+
* @param string $configPath
8160
* @param mixed $configValue
8261
* @param bool $expectedResult
8362
* @dataProvider isSetFlagDataProvider
8463
*/
85-
public function testIsSetFlag($configValue, $expectedResult)
64+
public function testIsSetFlag($configPath, $configValue, $expectedResult)
8665
{
87-
$path = 'some path';
88-
$configData = $this->getConfigDataMock('getValue');
89-
$configData->expects(
90-
$this->once()
66+
$this->appConfig->expects(
67+
$this->any()
9168
)->method(
92-
'getValue'
69+
'get'
9370
)->with(
94-
$this->equalTo($path)
71+
$this->equalTo('system'),
72+
$this->equalTo('default/' . $configPath)
9573
)->will(
9674
$this->returnValue($configValue)
9775
);
98-
$this->sectionPool->expects(
99-
$this->once()
100-
)->method(
101-
'getScope'
102-
)->with(
103-
$this->equalTo('default'),
104-
$this->isNull()
105-
)->will(
106-
$this->returnValue($configData)
107-
);
108-
$this->assertEquals($expectedResult, $this->model->isSetFlag($path));
76+
$this->assertEquals($expectedResult, $this->model->isSetFlag($configPath));
10977
}
11078

11179
public function isSetFlagDataProvider()
11280
{
11381
return [
114-
[0, false],
115-
[true, true],
116-
['0', false],
117-
['', false],
118-
['some string', true],
119-
[1, true]
82+
['a', 0, false],
83+
['b', true, true],
84+
['c', '0', false],
85+
['d', '', false],
86+
['e', 'some string', true],
87+
['f', 1, true]
12088
];
12189
}
12290

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

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

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

1011
/**
@@ -13,12 +14,12 @@
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
}
@@ -52,6 +51,7 @@ public function getCountries()
5251
->loadData()
5352
->toOptionArray(false);
5453
}
54+
5555
return $this->countries;
5656
}
5757
}

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\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>
@@ -379,7 +380,7 @@
379380
</arguments>
380381
</virtualType>
381382

382-
<!-- Value validators infrastructure -->
383+
<!-- Braintree validators infrastructure -->
383384
<virtualType name="BraintreeCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
384385
<arguments>
385386
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\Config</argument>
@@ -392,6 +393,22 @@
392393
</argument>
393394
</arguments>
394395
</virtualType>
396+
<!-- Braintree validators infrastructure -->
397+
398+
<!-- Braintree PayPal validators -->
399+
<virtualType name="BraintreePayPalCountryValidator" type="Magento\Payment\Gateway\Validator\CountryValidator">
400+
<arguments>
401+
<argument name="config" xsi:type="object">Magento\Braintree\Gateway\Config\PayPal\Config</argument>
402+
</arguments>
403+
</virtualType>
404+
<virtualType name="BraintreePayPalValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
405+
<arguments>
406+
<argument name="validators" xsi:type="array">
407+
<item name="country" xsi:type="string">BraintreePayPalCountryValidator</item>
408+
</argument>
409+
</arguments>
410+
</virtualType>
411+
<!-- END Braintree PayPal validators -->
395412

396413
<type name="Magento\Braintree\Block\Info">
397414
<arguments>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ define([
1111
'Magento_Braintree/js/view/payment/adapter',
1212
'Magento_Checkout/js/model/quote',
1313
'Magento_Checkout/js/model/full-screen-loader',
14-
'Magento_Checkout/js/model/payment/additional-validators'
15-
], function ($, _, Component, Braintree, quote, fullScreenLoader, additionalValidators) {
14+
'Magento_Checkout/js/model/payment/additional-validators',
15+
'Magento_Checkout/js/action/create-billing-address'
16+
], function (
17+
$,
18+
_,
19+
Component,
20+
Braintree,
21+
quote,
22+
fullScreenLoader,
23+
additionalValidators,
24+
createBillingAddress
25+
) {
1626
'use strict';
1727

1828
return Component.extend({
@@ -152,14 +162,16 @@ define([
152162
var billingAddress = {
153163
street: [address.streetAddress],
154164
city: address.locality,
155-
regionCode: address.region,
156165
postcode: address.postalCode,
157166
countryId: address.countryCodeAlpha2,
167+
email: customer.email,
158168
firstname: customer.firstName,
159169
lastname: customer.lastName,
160170
telephone: customer.phone
161171
};
162172

173+
billingAddress['region_code'] = address.region;
174+
billingAddress = createBillingAddress(billingAddress);
163175
quote.billingAddress(billingAddress);
164176
},
165177

0 commit comments

Comments
 (0)