Skip to content

Commit 016ba9a

Browse files
committed
Check if setting is disabled on default scope
1 parent 605ae1e commit 016ba9a

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ public function isReadOnly($path, $scope, $scopeCode = null)
6464
$this->placeholder->generate($path, $scope, $scopeCode)
6565
);
6666

67+
if (null === $config) {
68+
$config = $this->config->get(
69+
$this->resolvePath(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null) . "/" . $path
70+
);
71+
}
72+
6773
if (null === $config) {
6874
$config = $this->config->get($this->resolvePath($scope, $scopeCode) . "/" . $path);
6975
}

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

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,16 @@ public function setUp()
7171
* @param string $scopeCode
7272
* @param string|null $confValue
7373
* @param array $variables
74+
* @param array $configMap
7475
* @param bool $expectedResult
7576
* @dataProvider isReadonlyDataProvider
7677
*/
77-
public function testIsReadonly($path, $scope, $scopeCode, $confValue, array $variables, $expectedResult)
78+
public function testIsReadonly($path, $scope, $scopeCode, $confValue, array $variables, array $configMap, $expectedResult)
7879
{
79-
$this->placeholderMock->expects($this->once())
80+
$this->placeholderMock->expects($this->any())
8081
->method('isApplicable')
8182
->willReturn(true);
82-
$this->placeholderMock->expects($this->once())
83+
$this->placeholderMock->expects($this->any())
8384
->method('generate')
8485
->with($path, $scope, $scopeCode)
8586
->willReturn('SOME_PLACEHOLDER');
@@ -95,13 +96,13 @@ public function testIsReadonly($path, $scope, $scopeCode, $confValue, array $var
9596

9697
$this->configMock->expects($this->any())
9798
->method('get')
98-
->willReturnMap([
99+
->willReturnMap(array_merge([
99100
[
100101
'system/' . $scope . "/" . ($scopeCode ? $scopeCode . '/' : '') . $path,
101102
null,
102103
$confValue
103104
],
104-
]);
105+
], $configMap));
105106

106107
$this->assertSame($expectedResult, $this->checker->isReadOnly($path, $scope, $scopeCode));
107108
}
@@ -118,6 +119,7 @@ public function isReadonlyDataProvider()
118119
'scopeCode' => 'myWebsite',
119120
'confValue' => 'value',
120121
'variables' => [],
122+
'configMap' => [],
121123
'expectedResult' => true,
122124
],
123125
[
@@ -126,6 +128,7 @@ public function isReadonlyDataProvider()
126128
'scopeCode' => 'myWebsite',
127129
'confValue' => null,
128130
'variables' => ['SOME_PLACEHOLDER' => 'value'],
131+
'configMap' => [],
129132
'expectedResult' => true,
130133
],
131134
[
@@ -134,7 +137,58 @@ public function isReadonlyDataProvider()
134137
'scopeCode' => 'myWebsite',
135138
'confValue' => null,
136139
'variables' => [],
140+
'configMap' => [],
137141
'expectedResult' => false,
142+
],
143+
[
144+
'path' => 'general/web/locale',
145+
'scope' => 'website',
146+
'scopeCode' => 'myWebsite',
147+
'confValue' => null,
148+
'variables' => [],
149+
'configMap' => [
150+
[
151+
'system/default/general/web/locale',
152+
null,
153+
'default_value',
154+
],
155+
],
156+
'expectedResult' => true,
157+
],
158+
[
159+
'path' => 'general/web/locale',
160+
'scope' => 'website',
161+
'scopeCode' => 'myWebsite',
162+
'confValue' => null,
163+
'variables' => [],
164+
'configMap' => [
165+
[
166+
'system/default/general/web/locale',
167+
null,
168+
'default_value',
169+
],
170+
],
171+
'expectedResult' => true,
172+
],
173+
[
174+
'path' => 'general/web/locale',
175+
'scope' => 'store',
176+
'scopeCode' => 'myStore',
177+
'confValue' => null,
178+
'variables' => [],
179+
'configMap' => [
180+
[
181+
'system/default/general/web/locale',
182+
null,
183+
'default_value',
184+
],
185+
[
186+
'system/website/myWebsite/general/web/locale',
187+
null,
188+
null,
189+
],
190+
],
191+
'expectedResult' => true,
138192
]
139193
];
140194
}

0 commit comments

Comments
 (0)