Skip to content

Commit 397e22a

Browse files
author
Bohdan Korablov
committed
Merge branch 'MAGETWO-59376' of https://github.com/magento-falcons/magento2ce into MAGETWO-59376
2 parents c893f16 + 0f97776 commit 397e22a

File tree

8 files changed

+98
-15
lines changed

8 files changed

+98
-15
lines changed

app/code/Magento/Config/App/Config/Source/DumpConfigSourceAggregated.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function get($path = '')
7575
*
7676
* @param string $path
7777
* @param array $data
78+
* @return void
7879
*/
7980
private function filterChain($path, &$data)
8081
{
@@ -121,7 +122,7 @@ private function filterPath($path)
121122
}
122123

123124
/**
124-
* Sort sources
125+
* Sort sources ASC from higher priority to lower
125126
*
126127
* @return void
127128
*/

app/code/Magento/Config/Block/System/Config/Form.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ protected function _initElement(
431431
private function getStringScopeCode()
432432
{
433433
$scopeCode = $this->getData('scope_string_code');
434+
434435
if (null === $scopeCode) {
435436
if ($this->getStoreCode()) {
436437
$scopeCode = $this->_storeManager->getStore($this->getStoreCode())->getCode();
@@ -439,7 +440,8 @@ private function getStringScopeCode()
439440
} else {
440441
$scopeCode = '';
441442
}
442-
$this->setScopeStringCode($scopeCode);
443+
444+
$this->setData('scope_string_code', $scopeCode);
443445
}
444446

445447
return $scopeCode;

app/code/Magento/Config/Model/Config/Reader/Source/Deployed/SettingChecker.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ public function __construct(
6464
public function isReadOnly($path, $scope, $scopeCode = null)
6565
{
6666
$config = $this->getEnvValue(
67-
$this->placeholder->generate($path, $scope, $scopeCode),
68-
$this->config->get($this->resolvePath($scope, $scopeCode) . "/" . $path)
67+
$this->placeholder->generate($path, $scope, $scopeCode)
6968
);
7069

70+
if (null === $config) {
71+
$config = $this->config->get($this->resolvePath($scope, $scopeCode) . "/" . $path);
72+
}
73+
7174
return $config !== null;
7275
}
7376

@@ -79,7 +82,7 @@ public function isReadOnly($path, $scope, $scopeCode = null)
7982
* @param string $path
8083
* @param string $scope
8184
* @param string|null $scopeCode
82-
* @return mixed
85+
* @return string|null
8386
*/
8487
public function getPlaceholderValue($path, $scope, $scopeCode = null)
8588
{
@@ -90,10 +93,9 @@ public function getPlaceholderValue($path, $scope, $scopeCode = null)
9093
* Retrieve value of environment variable by placeholder
9194
*
9295
* @param string $placeholder
93-
* @param mixed $defaultValue
94-
* @return mixed
96+
* @return string|null
9597
*/
96-
public function getEnvValue($placeholder, $defaultValue = null)
98+
public function getEnvValue($placeholder)
9799
{
98100
if (null === $this->environmentVariables) {
99101
$this->environmentVariables = $_ENV;
@@ -103,7 +105,7 @@ public function getEnvValue($placeholder, $defaultValue = null)
103105
return $this->environmentVariables[$placeholder];
104106
}
105107

106-
return $defaultValue;
108+
return null;
107109
}
108110

109111

app/code/Magento/Config/Model/Placeholder/Environment.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
use Magento\Framework\App\DeploymentConfig;
1010

1111
/**
12-
* Class Environment
12+
* Class is used to work with placeholders for environment variables names based on config paths
1313
*/
1414
class Environment implements PlaceholderInterface
1515
{
16+
/**
17+
* @const string Prefix for placeholder
18+
*/
1619
const PREFIX = 'CONFIG__';
1720

1821
/**
@@ -29,6 +32,8 @@ public function __construct(DeploymentConfig $deploymentConfig)
2932
}
3033

3134
/**
35+
* Generates placeholder like CONFIG__DEFAULT__TEST__TEST_VALUE
36+
*
3237
* @inheritdoc
3338
*/
3439
public function generate($path, $scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)

app/code/Magento/Config/Test/Unit/App/Config/Source/DumpConfigSourceAggregatedTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,50 @@ public function testGet()
122122
);
123123
}
124124

125+
public function testGetExcludedFields()
126+
{
127+
$path = '';
128+
$data = [
129+
'default' => [
130+
'web' => [
131+
'unsecure' => [
132+
'base_url' => 'http://test.local',
133+
],
134+
'secure' => [
135+
'base_url' => 'https://test.local',
136+
]
137+
]
138+
],
139+
'test' => [
140+
'test' => [
141+
'test1' => [
142+
'test2' => [
143+
'test3' => 5,
144+
]
145+
]
146+
]
147+
]
148+
];
149+
150+
$this->sourceMock->expects($this->once())
151+
->method('get')
152+
->with($path)
153+
->willReturn($data);
154+
$this->sourceMockTwo->expects($this->once())
155+
->method('get')
156+
->with($path)
157+
->willReturn(['key' => 'value2']);
158+
$this->excludeListMock->expects($this->any())
159+
->method('isPresent')
160+
->willReturnMap([
161+
['web/unsecure/base_url', false],
162+
['web/secure/base_url', true],
163+
['test1/test2/test/3', false]
164+
]);
165+
166+
$this->assertEquals(
167+
['web/secure/base_url'],
168+
$this->model->getExcludedFields()
169+
);
170+
}
125171
}

app/code/Magento/Config/Test/Unit/Model/Config/Processor/EnvironmentPlaceholderTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class EnvironmentPlaceholderTest extends \PHPUnit_Framework_TestCase
3434
*/
3535
private $placeholderMock;
3636

37+
/**
38+
* @var array
39+
*/
40+
private $env;
41+
3742
protected function setUp()
3843
{
3944
$this->placeholderFactoryMock = $this->getMockBuilder(PlaceholderFactory::class)
@@ -44,6 +49,7 @@ protected function setUp()
4449
->getMock();
4550
$this->placeholderMock = $this->getMockBuilder(PlaceholderInterface::class)
4651
->getMockForAbstractClass();
52+
$this->env = $_ENV;
4753

4854
$this->placeholderFactoryMock->expects($this->any())
4955
->method('create')
@@ -58,7 +64,7 @@ protected function setUp()
5864
public function testProcess()
5965
{
6066
$_ENV = array_merge(
61-
$_ENV,
67+
$this->env,
6268
[
6369
'CONFIG_DEFAULT_TEST' => 1,
6470
'CONFIG_DEFAULT_TEST2' => 2,
@@ -117,4 +123,9 @@ public function testProcess()
117123
$this->model->process([])
118124
);
119125
}
126+
127+
protected function tearDown()
128+
{
129+
$_ENV = $this->env;
130+
}
120131
}

app/code/Magento/Config/Test/Unit/Model/Config/Reader/Source/Deployed/SettingCheckerTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class SettingCheckerTest extends \PHPUnit_Framework_TestCase
3838
*/
3939
private $checker;
4040

41+
/**
42+
* @var array
43+
*/
44+
private $env;
45+
4146
public function setUp()
4247
{
4348
$this->configMock = $this->getMockBuilder(DeploymentConfig::class)
@@ -51,6 +56,8 @@ public function setUp()
5156
$placeholderFactoryMock = $this->getMockBuilder(PlaceholderFactory::class)
5257
->disableOriginalConstructor()
5358
->getMock();
59+
$this->env = $_ENV;
60+
5461
$placeholderFactoryMock->expects($this->once())
5562
->method('create')
5663
->with(Environment::class)
@@ -66,9 +73,9 @@ public function setUp()
6673
* @param string|null $confValue
6774
* @param array $variables
6875
* @param bool $expectedResult
69-
* @dataProvider idDefinedDataProvider
76+
* @dataProvider isReadonlyDataProvider
7077
*/
71-
public function testIsDefined($path, $scope, $scopeCode, $confValue, array $variables, $expectedResult)
78+
public function testIsReadonly($path, $scope, $scopeCode, $confValue, array $variables, $expectedResult)
7279
{
7380
$this->placeholderMock->expects($this->once())
7481
->method('isApplicable')
@@ -85,7 +92,7 @@ public function testIsDefined($path, $scope, $scopeCode, $confValue, array $vari
8592
]
8693
);
8794

88-
$_ENV = array_merge($_ENV, $variables);
95+
$_ENV = array_merge($this->env, $variables);
8996

9097
$this->configMock->expects($this->any())
9198
->method('get')
@@ -103,7 +110,7 @@ public function testIsDefined($path, $scope, $scopeCode, $confValue, array $vari
103110
/**
104111
* @return array
105112
*/
106-
public function idDefinedDataProvider()
113+
public function isReadonlyDataProvider()
107114
{
108115
return [
109116
[
@@ -132,4 +139,9 @@ public function idDefinedDataProvider()
132139
]
133140
];
134141
}
142+
143+
protected function tearDown()
144+
{
145+
$_ENV = $this->env;
146+
}
135147
}

lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
class PhpFormatter implements FormatterInterface
1313
{
1414
/**
15+
* Format deployment configuration.
16+
* If $comments is present, each item will be added
17+
* as comment to the corresponding section
18+
*
1519
* {@inheritdoc}
1620
*/
1721
public function format($data, array $comments = [])

0 commit comments

Comments
 (0)