Skip to content

Commit d7f7a5e

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-46533-Mage-Mode' into PR_Branch
2 parents 7cf4e6b + b27924a commit d7f7a5e

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

setup/src/Magento/Setup/Model/ConfigGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ public function createXFrameConfig()
235235
public function createModeConfig()
236236
{
237237
$configData = new ConfigData(ConfigFilePool::APP_ENV);
238-
$configData->set(State::PARAM_MODE, State::MODE_DEFAULT);
238+
if ($this->deploymentConfig->get(State::PARAM_MODE) === null) {
239+
$configData->set(State::PARAM_MODE, State::MODE_DEFAULT);
240+
}
239241
return $configData;
240242
}
241243

setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Setup\Test\Unit\Model;
87

9-
108
use Magento\Framework\Config\ConfigOptionsListConstants;
9+
use Magento\Framework\App\State;
1110

1211
class ConfigGeneratorTest extends \PHPUnit_Framework_TestCase
1312
{
1413
/** @var \Magento\Framework\App\DeploymentConfig | \PHPUnit_Framework_MockObject_MockObject */
1514
private $deploymentConfigMock;
15+
1616
/** @var \Magento\Setup\Model\ConfigGenerator | \PHPUnit_Framework_MockObject_MockObject */
1717
private $model;
1818

@@ -58,4 +58,24 @@ public function testCreateCacheHostsConfig()
5858
$configData = $this->model->createCacheHostsConfig($data);
5959
$this->assertEquals($expectedData, $configData->getData()[ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS]);
6060
}
61+
62+
public function testCreateModeConfig()
63+
{
64+
$this->deploymentConfigMock->expects($this->once())
65+
->method('get')
66+
->with(State::PARAM_MODE)
67+
->willReturn(null);
68+
$configData = $this->model->createModeConfig();
69+
$this->assertSame(State::MODE_DEFAULT, $configData->getData()[State::PARAM_MODE]);
70+
}
71+
72+
public function testCreateModeConfigIfAlreadySet()
73+
{
74+
$this->deploymentConfigMock->expects($this->once())
75+
->method('get')
76+
->with(State::PARAM_MODE)
77+
->willReturn(State::MODE_PRODUCTION);
78+
$configData = $this->model->createModeConfig();
79+
$this->assertSame([], $configData->getData());
80+
}
6181
}

0 commit comments

Comments
 (0)