Skip to content

Commit 1a19ea5

Browse files
committed
Merge remote-tracking branch 'falcon/MAGETWO-69584' into falcons-pr-bugfixes
2 parents 66f52cc + 52ac131 commit 1a19ea5

File tree

9 files changed

+59
-37
lines changed

9 files changed

+59
-37
lines changed

app/code/Magento/Config/Console/Command/ConfigSet/ConfigSetProcessorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface ConfigSetProcessorInterface
2020
/**
2121
* Processes config:set command.
2222
*
23-
* @param string $path The configuration path in format group/section/field_name
23+
* @param string $path The configuration path in format section/group/field_name
2424
* @param string $value The configuration value
2525
* @param string $scope The configuration scope (default, website, or store)
2626
* @param string $scopeCode The scope code

app/code/Magento/Config/Console/Command/ConfigSet/ProcessorFacade.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Framework\Exception\ConfigurationMismatchException;
1313
use Magento\Framework\Exception\CouldNotSaveException;
1414
use Magento\Framework\Exception\ValidatorException;
15+
use Magento\Deploy\Model\DeploymentConfig\Hash;
16+
use Magento\Config\App\Config\Type\System;
1517

1618
/**
1719
* Processor facade for config:set command.
@@ -48,25 +50,35 @@ class ProcessorFacade
4850
*/
4951
private $configSetProcessorFactory;
5052

53+
/**
54+
* The hash manager.
55+
*
56+
* @var Hash
57+
*/
58+
private $hash;
59+
5160
/**
5261
* @param ValidatorInterface $scopeValidator The scope validator
5362
* @param PathValidator $pathValidator The path validator
5463
* @param ConfigSetProcessorFactory $configSetProcessorFactory The factory for config:set processors
64+
* @param Hash $hash The hash manager
5565
*/
5666
public function __construct(
5767
ValidatorInterface $scopeValidator,
5868
PathValidator $pathValidator,
59-
ConfigSetProcessorFactory $configSetProcessorFactory
69+
ConfigSetProcessorFactory $configSetProcessorFactory,
70+
Hash $hash
6071
) {
6172
$this->scopeValidator = $scopeValidator;
6273
$this->pathValidator = $pathValidator;
6374
$this->configSetProcessorFactory = $configSetProcessorFactory;
75+
$this->hash = $hash;
6476
}
6577

6678
/**
6779
* Processes config:set command.
6880
*
69-
* @param string $path The configuration path in format group/section/field_name
81+
* @param string $path The configuration path in format section/group/field_name
7082
* @param string $value The configuration value
7183
* @param string $scope The configuration scope (default, website, or store)
7284
* @param string $scopeCode The scope code
@@ -95,6 +107,8 @@ public function process($path, $value, $scope, $scopeCode, $lock)
95107
// The processing flow depends on --lock option.
96108
$processor->process($path, $value, $scope, $scopeCode);
97109

110+
$this->hash->regenerate(System::CONFIG_TYPE);
111+
98112
return $message;
99113
}
100114
}

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Config\App\Config\Type\System;
99
use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory;
1010
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
11-
use Magento\Deploy\Model\DeploymentConfig\Hash;
1211
use Magento\Framework\App\Config\ScopeConfigInterface;
1312
use Magento\Framework\Console\Cli;
1413
use Symfony\Component\Console\Command\Command;
@@ -49,13 +48,6 @@ class ConfigSetCommand extends Command
4948
*/
5049
private $changeDetector;
5150

52-
/**
53-
* The hash manager.
54-
*
55-
* @var Hash
56-
*/
57-
private $hash;
58-
5951
/**
6052
* The factory for processor facade.
6153
*
@@ -66,18 +58,15 @@ class ConfigSetCommand extends Command
6658
/**
6759
* @param EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor Emulator adminhtml area for CLI command
6860
* @param ChangeDetector $changeDetector The config change detector
69-
* @param Hash $hash The hash manager
7061
* @param ProcessorFacadeFactory $processorFacadeFactory The factory for processor facade
7162
*/
7263
public function __construct(
7364
EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor,
7465
ChangeDetector $changeDetector,
75-
Hash $hash,
7666
ProcessorFacadeFactory $processorFacadeFactory
7767
) {
7868
$this->emulatedAreaProcessor = $emulatedAreaProcessor;
7969
$this->changeDetector = $changeDetector;
80-
$this->hash = $hash;
8170
$this->processorFacadeFactory = $processorFacadeFactory;
8271

8372
parent::__construct();
@@ -94,7 +83,7 @@ protected function configure()
9483
new InputArgument(
9584
static::ARG_PATH,
9685
InputArgument::REQUIRED,
97-
'Configuration path in format group/section/field_name'
86+
'Configuration path in format section/group/field_name'
9887
),
9988
new InputArgument(static::ARG_VALUE, InputArgument::REQUIRED, 'Configuration value'),
10089
new InputOption(
@@ -150,8 +139,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
150139
);
151140
});
152141

153-
$this->hash->regenerate(System::CONFIG_TYPE);
154-
155142
$output->writeln('<info>' . $message . '</info>');
156143

157144
return Cli::RETURN_SUCCESS;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function __construct(
8484
/**
8585
* Returns instance of Value with defined properties.
8686
*
87-
* @param string $path The configuration path in format group/section/field_name
87+
* @param string $path The configuration path in format section/group/field_name
8888
* @param string $value The configuration value
8989
* @param string $scope The configuration scope (default, website, or store)
9090
* @param string|int|null $scopeCode The scope code

app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/ProcessorFacadeTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Magento\Framework\Exception\ValidatorException;
1616
use Magento\Framework\Exception\CouldNotSaveException;
1717
use Magento\Framework\Exception\ConfigurationMismatchException;
18+
use Magento\Deploy\Model\DeploymentConfig\Hash;
19+
use Magento\Config\App\Config\Type\System;
1820
use PHPUnit_Framework_MockObject_MockObject as Mock;
1921

2022
/**
@@ -49,6 +51,11 @@ class ProcessorFacadeTest extends \PHPUnit_Framework_TestCase
4951
*/
5052
private $processorMock;
5153

54+
/**
55+
* @var Hash|Mock
56+
*/
57+
private $hashMock;
58+
5259
/**
5360
* @inheritdoc
5461
*/
@@ -69,10 +76,15 @@ protected function setUp()
6976
->method('create')
7077
->willReturn($this->processorMock);
7178

79+
$this->hashMock = $this->getMockBuilder(Hash::class)
80+
->disableOriginalConstructor()
81+
->getMock();
82+
7283
$this->model = new ProcessorFacade(
7384
$this->scopeValidatorMock,
7485
$this->pathValidatorMock,
75-
$this->configSetProcessorFactoryMock
86+
$this->configSetProcessorFactoryMock,
87+
$this->hashMock
7688
);
7789
}
7890

@@ -91,6 +103,9 @@ public function testProcess()
91103
$this->processorMock->expects($this->once())
92104
->method('process')
93105
->with('test/test/test', 'test', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
106+
$this->hashMock->expects($this->once())
107+
->method('regenerate')
108+
->with(System::CONFIG_TYPE);
94109

95110
$this->assertSame(
96111
'Value was saved.',

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
*/
66
namespace Magento\Config\Test\Unit\Console\Command;
77

8-
use Magento\Config\App\Config\Type\System;
98
use Magento\Config\Console\Command\ConfigSet\ProcessorFacadeFactory;
9+
use Magento\Config\Console\Command\ConfigSet\ProcessorFacade;
1010
use Magento\Config\Console\Command\ConfigSetCommand;
1111
use Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor;
1212
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
13-
use Magento\Deploy\Model\DeploymentConfig\Hash;
1413
use Magento\Framework\Console\Cli;
1514
use Magento\Framework\Exception\ValidatorException;
1615
use PHPUnit_Framework_MockObject_MockObject as Mock;
@@ -39,14 +38,14 @@ class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase
3938
private $changeDetectorMock;
4039

4140
/**
42-
* @var Hash|Mock
41+
* @var ProcessorFacadeFactory|Mock
4342
*/
44-
private $hashMock;
43+
private $processorFacadeFactoryMock;
4544

4645
/**
47-
* @var ProcessorFacadeFactory|Mock
46+
* @var ProcessorFacade|Mock
4847
*/
49-
private $processorFacadeFactoryMock;
48+
private $processorFacadeMock;
5049

5150
/**
5251
* @inheritdoc
@@ -59,17 +58,16 @@ protected function setUp()
5958
$this->changeDetectorMock = $this->getMockBuilder(ChangeDetector::class)
6059
->disableOriginalConstructor()
6160
->getMock();
62-
$this->hashMock = $this->getMockBuilder(Hash::class)
61+
$this->processorFacadeFactoryMock = $this->getMockBuilder(ProcessorFacadeFactory::class)
6362
->disableOriginalConstructor()
6463
->getMock();
65-
$this->processorFacadeFactoryMock = $this->getMockBuilder(ProcessorFacadeFactory::class)
64+
$this->processorFacadeMock = $this->getMockBuilder(ProcessorFacade::class)
6665
->disableOriginalConstructor()
6766
->getMock();
6867

6968
$this->command = new ConfigSetCommand(
7069
$this->emulatedAreProcessorMock,
7170
$this->changeDetectorMock,
72-
$this->hashMock,
7371
$this->processorFacadeFactoryMock
7472
);
7573
}
@@ -79,12 +77,17 @@ public function testExecute()
7977
$this->changeDetectorMock->expects($this->once())
8078
->method('hasChanges')
8179
->willReturn(false);
82-
$this->emulatedAreProcessorMock->expects($this->once())
80+
$this->processorFacadeFactoryMock->expects($this->once())
81+
->method('create')
82+
->willReturn($this->processorFacadeMock);
83+
$this->processorFacadeMock->expects($this->once())
8384
->method('process')
8485
->willReturn('Some message');
85-
$this->hashMock->expects($this->once())
86-
->method('regenerate')
87-
->with(System::CONFIG_TYPE);
86+
$this->emulatedAreProcessorMock->expects($this->once())
87+
->method('process')
88+
->willReturnCallback(function ($function) {
89+
return $function();
90+
});
8891

8992
$tester = new CommandTester($this->command);
9093
$tester->execute([

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ protected function setUp()
125125
);
126126
}
127127

128-
/**
129-
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
130-
*/
131128
public function testImport()
132129
{
133130
$data = [];
@@ -150,6 +147,7 @@ public function testImport()
150147
->method('emulateAreaCode')
151148
->with(Area::AREA_ADMINHTML, $this->anything())
152149
->willReturnCallback(function ($area, $function) {
150+
$this->assertEquals(Area::AREA_ADMINHTML, $area);
153151
return $function();
154152
});
155153
$this->saveProcessorMock->expects($this->once())

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected function configure()
104104
$this->addArgument(
105105
self::INPUT_ARGUMENT_PATH,
106106
InputArgument::OPTIONAL,
107-
'Configuration path for example group/section/field_name'
107+
'Configuration path for example section/group/field_name'
108108
);
109109
$this->addArgument(
110110
self::INPUT_ARGUMENT_VALUE,
@@ -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)