Skip to content

Commit 3d2a23c

Browse files
committed
Merge remote-tracking branch 'falcon/MAGETWO-67274' into falcons-pr-bugfixes-2
2 parents 14ea31c + 6105a6d commit 3d2a23c

File tree

8 files changed

+59
-147
lines changed

8 files changed

+59
-147
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ public function __construct(
6666
*/
6767
public function process($path, $value, $scope, $scopeCode)
6868
{
69-
if (!$this->deploymentConfig->isAvailable()) {
70-
throw new CouldNotSaveException(
71-
__(
72-
'We can\'t save this option because Magento is not installed. '
73-
. 'To lock this value, enter the command again using the --%1 option.',
74-
ConfigSetCommand::OPTION_LOCK
75-
)
76-
);
77-
}
78-
7969
if ($this->isLocked($path, $scope, $scopeCode)) {
8070
throw new CouldNotSaveException(
8171
__(

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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\Framework\App\DeploymentConfig;
1112
use Magento\Framework\App\Config\ScopeConfigInterface;
1213
use Magento\Framework\Console\Cli;
1314
use Symfony\Component\Console\Command\Command;
@@ -55,19 +56,29 @@ class ConfigSetCommand extends Command
5556
*/
5657
private $processorFacadeFactory;
5758

59+
/**
60+
* Application deployment configuration
61+
*
62+
* @var DeploymentConfig
63+
*/
64+
private $deploymentConfig;
65+
5866
/**
5967
* @param EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor Emulator adminhtml area for CLI command
6068
* @param ChangeDetector $changeDetector The config change detector
6169
* @param ProcessorFacadeFactory $processorFacadeFactory The factory for processor facade
70+
* @param DeploymentConfig $deploymentConfig Application deployment configuration
6271
*/
6372
public function __construct(
6473
EmulatedAdminhtmlAreaProcessor $emulatedAreaProcessor,
6574
ChangeDetector $changeDetector,
66-
ProcessorFacadeFactory $processorFacadeFactory
75+
ProcessorFacadeFactory $processorFacadeFactory,
76+
DeploymentConfig $deploymentConfig
6777
) {
6878
$this->emulatedAreaProcessor = $emulatedAreaProcessor;
6979
$this->changeDetector = $changeDetector;
7080
$this->processorFacadeFactory = $processorFacadeFactory;
81+
$this->deploymentConfig = $deploymentConfig;
7182

7283
parent::__construct();
7384
}
@@ -117,6 +128,12 @@ protected function configure()
117128
*/
118129
protected function execute(InputInterface $input, OutputInterface $output)
119130
{
131+
if (!$this->deploymentConfig->isAvailable()) {
132+
$output->writeln(
133+
'<error>You cannot run this command because the Magento application is not installed.</error>'
134+
);
135+
return Cli::RETURN_FAILURE;
136+
}
120137
if ($this->changeDetector->hasChanges(System::CONFIG_TYPE)) {
121138
$output->writeln(
122139
'<error>'

app/code/Magento/Config/Console/CommandList.php

Lines changed: 0 additions & 50 deletions
This file was deleted.

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,6 @@ private function configMockForProcessTest($path, $scope, $scopeCode)
162162
->willReturnMap([
163163
['system/default/test/test/test', null],
164164
]);
165-
$this->deploymentConfigMock->expects($this->once())
166-
->method('isAvailable')
167-
->willReturn(true);
168-
}
169-
170-
/**
171-
* @expectedException \Magento\Framework\Exception\LocalizedException
172-
* @expectedExceptionMessage We can't save this option because Magento is not installed.
173-
*/
174-
public function testProcessNotInstalled()
175-
{
176-
$path = 'test/test/test';
177-
$value = 'value';
178-
179-
$this->deploymentConfigMock->expects($this->once())
180-
->method('isAvailable')
181-
->willReturn(false);
182-
183-
$this->model->process($path, $value, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
184165
}
185166

186167
/**
@@ -192,9 +173,6 @@ public function testProcessLockedValue()
192173
$path = 'test/test/test';
193174
$value = 'value';
194175

195-
$this->deploymentConfigMock->expects($this->once())
196-
->method('isAvailable')
197-
->willReturn(true);
198176
$this->deploymentConfigMock->expects($this->once())
199177
->method('get')
200178
->willReturnMap([

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Config\Console\Command\ConfigSetCommand;
1111
use Magento\Config\Console\Command\EmulatedAdminhtmlAreaProcessor;
1212
use Magento\Deploy\Model\DeploymentConfig\ChangeDetector;
13+
use Magento\Framework\App\DeploymentConfig;
1314
use Magento\Framework\Console\Cli;
1415
use Magento\Framework\Exception\ValidatorException;
1516
use PHPUnit_Framework_MockObject_MockObject as Mock;
@@ -42,6 +43,11 @@ class ConfigSetCommandTest extends \PHPUnit_Framework_TestCase
4243
*/
4344
private $processorFacadeFactoryMock;
4445

46+
/**
47+
* @var DeploymentConfig|Mock
48+
*/
49+
private $deploymentConfigMock;
50+
4551
/**
4652
* @var ProcessorFacade|Mock
4753
*/
@@ -64,16 +70,23 @@ protected function setUp()
6470
$this->processorFacadeMock = $this->getMockBuilder(ProcessorFacade::class)
6571
->disableOriginalConstructor()
6672
->getMock();
73+
$this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
74+
->disableOriginalConstructor()
75+
->getMock();
6776

6877
$this->command = new ConfigSetCommand(
6978
$this->emulatedAreProcessorMock,
7079
$this->changeDetectorMock,
71-
$this->processorFacadeFactoryMock
80+
$this->processorFacadeFactoryMock,
81+
$this->deploymentConfigMock
7282
);
7383
}
7484

7585
public function testExecute()
7686
{
87+
$this->deploymentConfigMock->expects($this->once())
88+
->method('isAvailable')
89+
->willReturn(true);
7790
$this->changeDetectorMock->expects($this->once())
7891
->method('hasChanges')
7992
->willReturn(false);
@@ -102,8 +115,32 @@ public function testExecute()
102115
$this->assertSame(Cli::RETURN_SUCCESS, $tester->getStatusCode());
103116
}
104117

118+
public function testExecuteMagentoUninstalled()
119+
{
120+
$this->deploymentConfigMock->expects($this->once())
121+
->method('isAvailable')
122+
->willReturn(false);
123+
$this->emulatedAreProcessorMock->expects($this->never())
124+
->method('process');
125+
126+
$tester = new CommandTester($this->command);
127+
$tester->execute([
128+
ConfigSetCommand::ARG_PATH => 'test/test/test',
129+
ConfigSetCommand::ARG_VALUE => 'value'
130+
]);
131+
132+
$this->assertContains(
133+
__('You cannot run this command because the Magento application is not installed.')->render(),
134+
$tester->getDisplay()
135+
);
136+
$this->assertSame(Cli::RETURN_FAILURE, $tester->getStatusCode());
137+
}
138+
105139
public function testExecuteNeedsRegeneration()
106140
{
141+
$this->deploymentConfigMock->expects($this->once())
142+
->method('isAvailable')
143+
->willReturn(true);
107144
$this->changeDetectorMock->expects($this->once())
108145
->method('hasChanges')
109146
->willReturn(true);
@@ -125,6 +162,9 @@ public function testExecuteNeedsRegeneration()
125162

126163
public function testExecuteWithException()
127164
{
165+
$this->deploymentConfigMock->expects($this->once())
166+
->method('isAvailable')
167+
->willReturn(true);
128168
$this->changeDetectorMock->expects($this->once())
129169
->method('hasChanges')
130170
->willReturn(false);

app/code/Magento/Config/Test/Unit/Console/CommandListTest.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

app/code/Magento/Config/cli_commands.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/code/Magento/Config/composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
],
2121
"autoload": {
2222
"files": [
23-
"cli_commands.php",
2423
"registration.php"
2524
],
2625
"psr-4": {

0 commit comments

Comments
 (0)