Skip to content

Commit 4177694

Browse files
author
Bohdan Korablov
committed
MAGETWO-69584: Command config:sensitive:set does not work on the cloud
1 parent 04b3b52 commit 4177694

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
138138

139139
try {
140140
$message = $this->emulatedAreaProcessor->process(function () use ($input) {
141-
return $this->processorFacadeFactory->create()->process(
141+
$message = $this->processorFacadeFactory->create()->process(
142142
$input->getArgument(static::ARG_PATH),
143143
$input->getArgument(static::ARG_VALUE),
144144
$input->getOption(static::OPTION_SCOPE),
145145
$input->getOption(static::OPTION_SCOPE_CODE),
146146
$input->getOption(static::OPTION_LOCK)
147147
);
148-
});
149148

150-
$this->hash->regenerate(System::CONFIG_TYPE);
149+
$this->hash->regenerate(System::CONFIG_TYPE);
150+
151+
return $message;
152+
});
151153

152154
$output->writeln('<info>' . $message . '</info>');
153155

app/code/Magento/Config/Model/Config/Importer.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,14 @@ public function import(array $data)
135135
$this->scopeConfig->clean();
136136
}
137137

138-
$this->state->emulateAreaCode(Area::AREA_ADMINHTML, function () use ($changedData) {
138+
$this->state->emulateAreaCode(Area::AREA_ADMINHTML, function () use ($changedData, $data, $flag) {
139139
$this->scope->setCurrentScope(Area::AREA_ADMINHTML);
140140

141141
// Invoke saving of new values.
142142
$this->saveProcessor->process($changedData);
143+
$flag->setFlagData($data);
144+
$this->flagResource->save($flag);
143145
});
144-
145-
$flag->setFlagData($data);
146-
$this->flagResource->save($flag);
147146
} catch (\Exception $e) {
148147
throw new InvalidTransitionException(__('%1', $e->getMessage()), $e);
149148
} finally {

app/code/Magento/Config/Test/Unit/Console/Command/ConfigSetCommandTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Config\App\Config\Type\System;
99
use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory;
10+
use Magento\Config\Console\Command\ConfigSet\ProcessorFacade;
1011
use Magento\Config\Console\Command\ConfigSetCommand;
1112
use Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor;
1213
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
@@ -48,6 +49,11 @@ class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase
4849
*/
4950
private $processorFacadeFactoryMock;
5051

52+
/**
53+
* @var ProcessorFacade|Mock
54+
*/
55+
private $processorFacadeMock;
56+
5157
/**
5258
* @inheritdoc
5359
*/
@@ -65,6 +71,9 @@ protected function setUp()
6571
$this->processorFacadeFactoryMock = $this->getMockBuilder(ProcessorFacadeFactory::class)
6672
->disableOriginalConstructor()
6773
->getMock();
74+
$this->processorFacadeMock = $this->getMockBuilder(ProcessorFacade::class)
75+
->disableOriginalConstructor()
76+
->getMock();
6877

6978
$this->command = new ConfigSetCommand(
7079
$this->emulatedAreProcessorMock,
@@ -79,9 +88,17 @@ public function testExecute()
7988
$this->changeDetectorMock->expects($this->once())
8089
->method('hasChanges')
8190
->willReturn(false);
82-
$this->emulatedAreProcessorMock->expects($this->once())
91+
$this->processorFacadeFactoryMock->expects($this->once())
92+
->method('create')
93+
->willReturn($this->processorFacadeMock);
94+
$this->processorFacadeMock->expects($this->once())
8395
->method('process')
8496
->willReturn('Some message');
97+
$this->emulatedAreProcessorMock->expects($this->once())
98+
->method('process')
99+
->willReturnCallback(function ($function) {
100+
return $function();
101+
});
85102
$this->hashMock->expects($this->once())
86103
->method('regenerate')
87104
->with(System::CONFIG_TYPE);

app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,14 @@ public function testImport()
153153
->willReturn('oldScope');
154154
$this->stateMock->expects($this->once())
155155
->method('emulateAreaCode')
156-
->with(Area::AREA_ADMINHTML, $this->anything());
157-
$this->scopeMock->expects($this->once())
156+
->with(Area::AREA_ADMINHTML, $this->anything())
157+
->willReturnCallback(function ($area, $function) {
158+
return $function();
159+
});
160+
$this->scopeMock->expects($this->at(1))
161+
->method('setCurrentScope')
162+
->with('adminhtml');
163+
$this->scopeMock->expects($this->at(2))
158164
->method('setCurrentScope')
159165
->with('oldScope');
160166
$this->flagMock->expects($this->once())

app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSetCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
155155
try {
156156
$this->emulatedAreaProcessor->process(function () use ($input, $output) {
157157
$this->facade->process($input, $output);
158+
$this->hash->regenerate(System::CONFIG_TYPE);
158159
});
159-
$this->hash->regenerate(System::CONFIG_TYPE);
160160

161161
return Cli::RETURN_SUCCESS;
162162
} catch (\Exception $e) {

app/code/Magento/Deploy/Test/Unit/Console/Command/App/SensitiveConfigSetCommandTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function testExecute()
7777
->method('hasChanges')
7878
->willReturn(false);
7979
$this->emulatedAreaProcessorMock->expects($this->once())
80+
->method('process')
81+
->willReturnCallback(function ($function) {
82+
return $function();
83+
});
84+
$this->facadeMock->expects($this->once())
8085
->method('process');
8186
$this->hashMock->expects($this->once())
8287
->method('regenerate')

0 commit comments

Comments
 (0)