Skip to content

Commit f1fd57a

Browse files
Merge branches 'MAGETWO-62736', 'MAGETWO-63381' and 'MAGETWO-65085' of https://github.com/magento-falcons/magento2ce into MAGETWO-65085
3 parents 20f7197 + e19d350 + 7200c68 commit f1fd57a

File tree

4 files changed

+77
-22
lines changed

4 files changed

+77
-22
lines changed

app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class ValueProcessor
2121
{
2222
/**
2323
* Placeholder for the output of sensitive data.
24-
*
25-
* @const
2624
*/
2725
const SAFE_PLACEHOLDER = '******';
2826

@@ -63,7 +61,7 @@ public function __construct(
6361
}
6462

6563
/**
66-
* Processes value using backend model.
64+
* Processes value to display using backend model.
6765
*
6866
* @param string $scope The scope of configuration. E.g. 'default', 'website' or 'store'
6967
* @param string $scopeCode The scope code of configuration
@@ -86,14 +84,17 @@ public function process($scope, $scopeCode, $value, $path)
8684
$backendModel = $field && $field->hasBackendModel()
8785
? $field->getBackendModel()
8886
: $this->configValueFactory->create();
87+
88+
if ($backendModel instanceof Encrypted) {
89+
return $value ? self::SAFE_PLACEHOLDER : null;
90+
}
91+
8992
$backendModel->setPath($path);
9093
$backendModel->setScope($scope);
9194
$backendModel->setScopeId($scopeCode);
9295
$backendModel->setValue($value);
9396
$backendModel->afterLoad();
9497

95-
return ($backendModel instanceof Encrypted) && !empty($backendModel->getValue())
96-
? self::SAFE_PLACEHOLDER
97-
: $backendModel->getValue();
98+
return $backendModel->getValue();
9899
}
99100
}

app/code/Magento/Config/Console/Command/ConfigShowCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
144144
try {
145145
$this->scope = $input->getOption(self::INPUT_OPTION_SCOPE);
146146
$this->scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE);
147-
$this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH), "/");
147+
$this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH), '/');
148148

149149
$this->scopeValidator->isValid($this->scope, $this->scopeCode);
150150
$configPath = $this->pathResolver->resolve($this->inputPath, $this->scope, $this->scopeCode);

app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,33 @@ protected function setUp()
6666
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsGetBackendModel
6767
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCreate
6868
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsGetValue
69+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetPath
70+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetScope
71+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetScopeId
72+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetValue
73+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsAfterLoad
6974
* @param string $expectsValue
7075
* @param string $className
76+
* @param string $value
7177
* @dataProvider processDataProvider
78+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7279
*/
7380
public function testProcess(
7481
$hasBackendModel,
7582
$expectsGetBackendModel,
7683
$expectsCreate,
7784
$expectsGetValue,
85+
$expectsSetPath,
86+
$expectsSetScope,
87+
$expectsSetScopeId,
88+
$expectsSetValue,
89+
$expectsAfterLoad,
7890
$expectsValue,
79-
$className
91+
$className,
92+
$value
8093
) {
8194
$scope = 'someScope';
8295
$scopeCode = 'someScopeCode';
83-
$value = 'someValue';
8496
$path = 'some/config/path';
8597
$oldConfigScope = 'oldConfigScope';
8698

@@ -107,23 +119,23 @@ public function testProcess(
107119
->disableOriginalConstructor()
108120
->setMethods(['setPath', 'setScope', 'setScopeId', 'setValue', 'getValue', 'afterLoad'])
109121
->getMock();
110-
$backendModelMock->expects($this->once())
122+
$backendModelMock->expects($expectsSetPath)
111123
->method('setPath')
112124
->with($path)
113125
->willReturnSelf();
114-
$backendModelMock->expects($this->once())
126+
$backendModelMock->expects($expectsSetScope)
115127
->method('setScope')
116128
->with($scope)
117129
->willReturnSelf();
118-
$backendModelMock->expects($this->once())
130+
$backendModelMock->expects($expectsSetScopeId)
119131
->method('setScopeId')
120132
->with($scopeCode)
121133
->willReturnSelf();
122-
$backendModelMock->expects($this->once())
134+
$backendModelMock->expects($expectsSetValue)
123135
->method('setValue')
124136
->with($value)
125137
->willReturnSelf();
126-
$backendModelMock->expects($this->once())
138+
$backendModelMock->expects($expectsAfterLoad)
127139
->method('afterLoad')
128140
->willReturnSelf();
129141
$backendModelMock->expects($expectsGetValue)
@@ -154,6 +166,7 @@ public function testProcess(
154166

155167
/**
156168
* @return array
169+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
157170
*/
158171
public function processDataProvider()
159172
{
@@ -163,24 +176,70 @@ public function processDataProvider()
163176
'expectsGetBackendModel' => $this->once(),
164177
'expectsCreate' => $this->never(),
165178
'expectsGetValue' => $this->once(),
179+
'expectsSetPath' => $this->once(),
180+
'expectsSetScope' => $this->once(),
181+
'expectsSetScopeId' => $this->once(),
182+
'expectsSetValue' => $this->once(),
183+
'expectsAfterLoad' => $this->once(),
166184
'expectsValue' => 'someValue',
167-
'className' => Value::class
185+
'className' => Value::class,
186+
'value' => 'someValue'
168187
],
169188
[
170189
'hasBackendModel' => false,
171190
'expectsGetBackendModel' => $this->never(),
172191
'expectsCreate' => $this->once(),
173192
'expectsGetValue' => $this->once(),
193+
'expectsSetPath' => $this->once(),
194+
'expectsSetScope' => $this->once(),
195+
'expectsSetScopeId' => $this->once(),
196+
'expectsSetValue' => $this->once(),
197+
'expectsAfterLoad' => $this->once(),
174198
'expectsValue' => 'someValue',
175-
'className' => Value::class
199+
'className' => Value::class,
200+
'value' => 'someValue'
176201
],
177202
[
178203
'hasBackendModel' => true,
179204
'expectsGetBackendModel' => $this->once(),
180205
'expectsCreate' => $this->never(),
181-
'expectsGetValue' => $this->once(),
206+
'expectsGetValue' => $this->never(),
207+
'expectsSetPath' => $this->never(),
208+
'expectsSetScope' => $this->never(),
209+
'expectsSetScopeId' => $this->never(),
210+
'expectsSetValue' => $this->never(),
211+
'expectsAfterLoad' => $this->never(),
182212
'expectsValue' => ValueProcessor::SAFE_PLACEHOLDER,
183213
'className' => Encrypted::class,
214+
'value' => 'someValue'
215+
],
216+
[
217+
'hasBackendModel' => true,
218+
'expectsGetBackendModel' => $this->once(),
219+
'expectsCreate' => $this->never(),
220+
'expectsGetValue' => $this->once(),
221+
'expectsSetPath' => $this->once(),
222+
'expectsSetScope' => $this->once(),
223+
'expectsSetScopeId' => $this->once(),
224+
'expectsSetValue' => $this->once(),
225+
'expectsAfterLoad' => $this->once(),
226+
'expectsValue' => null,
227+
'className' => Value::class,
228+
'value' => null
229+
],
230+
[
231+
'hasBackendModel' => true,
232+
'expectsGetBackendModel' => $this->once(),
233+
'expectsCreate' => $this->never(),
234+
'expectsGetValue' => $this->never(),
235+
'expectsSetPath' => $this->never(),
236+
'expectsSetScope' => $this->never(),
237+
'expectsSetScopeId' => $this->never(),
238+
'expectsSetValue' => $this->never(),
239+
'expectsAfterLoad' => $this->never(),
240+
'expectsValue' => null,
241+
'className' => Encrypted::class,
242+
'value' => null
184243
],
185244
];
186245
}

lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ protected function setUp()
6161
->expects($this->any())
6262
->method('getPaths')
6363
->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'env.php']);
64-
$this->configFilePool
65-
->expects($this->any())
66-
->method('getInitialFilePools')
67-
->willReturn([]);
6864
}
6965

7066
public function testGetFile()
@@ -107,7 +103,6 @@ public function testCustomLoad($file, $expected)
107103
$configFilePool = $this->getMock(\Magento\Framework\Config\File\ConfigFilePool::class, [], [], '', false);
108104
$configFilePool->expects($this->any())->method('getPaths')->willReturn([$file]);
109105
$configFilePool->expects($this->any())->method('getPath')->willReturn($file);
110-
$configFilePool->expects($this->any())->method('getInitialFilePools')->willReturn([]);
111106
$object = new Reader($this->dirList, $this->driverPool, $configFilePool, $file);
112107
$this->assertSame($expected, $object->load($file));
113108
}

0 commit comments

Comments
 (0)