Skip to content

Commit 205e6ec

Browse files
committed
MAGETWO-33555: [GITHUB] After update, config.php is not updated with correct sequence #1015
- CR fixes
1 parent e60bdfa commit 205e6ec

File tree

7 files changed

+62
-69
lines changed

7 files changed

+62
-69
lines changed

dev/tests/unit/testsuite/Magento/Framework/Module/ModuleList/DeploymentConfigFactoryTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
class DeploymentConfigFactoryTest extends \PHPUnit_Framework_TestCase
1010
{
1111
/**
12-
* @var Magento\Framework\Module\ModuleList\DeploymentConfigFactory
12+
* @var DeploymentConfigFactory
1313
*/
1414
protected $object;
1515

1616
public function testCreate()
1717
{
18-
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
19-
$this->object = $helper->getObject('Magento\Framework\Module\ModuleList\DeploymentConfigFactory');
20-
$this->object->create(['Module_One' => 0, 'Module_Two' =>1]);
18+
$this->object = new DeploymentConfigFactory();
19+
$this->assertInstanceOf(
20+
'Magento\Framework\Module\ModuleList\DeploymentConfig',
21+
$this->object->create(['Module_One' => 0, 'Module_Two' =>1])
22+
);
2123
}
2224
}

dev/tests/unit/testsuite/Magento/Setup/Controller/ConsoleControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ public function testInstallDataAction()
163163

164164
public function testUpdateAction()
165165
{
166-
$this->installer->expects($this->once())->method('installSchema');
167-
$this->installer->expects($this->once())->method('installDataFixtures');
168-
$this->installer->expects($this->once())->method('updateModulesInDeploymentConfig');
166+
$this->installer->expects($this->at(0))->method('updateModulesSequence');
167+
$this->installer->expects($this->at(1))->method('installSchema');
168+
$this->installer->expects($this->at(2))->method('installDataFixtures');
169169
$this->controller->updateAction();
170170
}
171171

dev/tests/unit/testsuite/Magento/Setup/Model/InstallerTest.php

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
4747
*/
4848
private $moduleList;
4949

50+
/**
51+
* @var \Magento\Framework\Module\ModuleList\Loader|\PHPUnit_Framework_MockObject_MockObject
52+
*/
53+
private $moduleLoader;
54+
55+
/**
56+
* @var \Magento\Framework\Module\ModuleList\DeploymentConfigFactory|\PHPUnit_Framework_MockObject_MockObject
57+
*/
58+
private $deploymentConfigFactory;
59+
60+
/**
61+
* @var \Magento\Framework\Module\ModuleList\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
62+
*/
63+
private $deploymentConfig;
64+
5065
/**
5166
* @var \Magento\Framework\App\Filesystem\DirectoryList|\PHPUnit_Framework_MockObject_MockObject
5267
*/
@@ -128,6 +143,21 @@ protected function setUp()
128143
$this->moduleList->expects($this->any())->method('getNames')->willReturn(
129144
['Foo_One', 'Bar_Two']
130145
);
146+
$this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false);
147+
$this->deploymentConfigFactory = $this->getMock(
148+
'Magento\Framework\Module\ModuleList\DeploymentConfigFactory',
149+
[],
150+
[],
151+
'',
152+
false
153+
);
154+
$this->deploymentConfig = $this->getMock(
155+
'Magento\Framework\Module\ModuleList\DeploymentConfig',
156+
[],
157+
[],
158+
'',
159+
false
160+
);
131161
$this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false);
132162
$this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false);
133163
$this->logger = $this->getMockForAbstractClass('Magento\Setup\Model\LoggerInterface');
@@ -146,16 +176,9 @@ protected function setUp()
146176
*
147177
* @param \PHPUnit_Framework_MockObject_MockObject|bool $connectionFactory
148178
* @param \PHPUnit_Framework_MockObject_MockObject|bool $objectManagerProvider
149-
* @param \PHPUnit_Framework_MockObject_MockObject|bool $moduleLoader
150-
* @param \PHPUnit_Framework_MockObject_MockObject|bool $deploymentConfigFactory
151179
* @return Installer
152180
*/
153-
private function createObject(
154-
$connectionFactory = false,
155-
$objectManagerProvider = false,
156-
$moduleLoader = false,
157-
$deploymentConfigFactory = false
158-
) {
181+
private function createObject($connectionFactory = false, $objectManagerProvider = false) {
159182
if (!$connectionFactory) {
160183
$connectionFactory = $this->getMock('Magento\Setup\Module\ConnectionFactory', [], [], '', false);
161184
$connectionFactory->expects($this->any())->method('create')->willReturn($this->connection);
@@ -164,42 +187,15 @@ private function createObject(
164187
$objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false);
165188
$objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager);
166189
}
167-
if (!$moduleLoader) {
168-
$moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false);
169-
$allModules = [
170-
'Foo_One' => [],
171-
'Bar_Two' => [],
172-
];
173-
$moduleLoader->expects($this->any())->method('load')->willReturn($allModules);
174-
}
175-
if (!$deploymentConfigFactory) {
176-
$deploymentConfigFactory = $this->getMock(
177-
'Magento\Framework\Module\ModuleList\DeploymentConfigFactory',
178-
[],
179-
[],
180-
'',
181-
false
182-
);
183-
$modules = ['Foo_One' => 1, 'Bar_Two' => 1 ];
184-
$deploymentConfig = $this->getMock(
185-
'Magento\Framework\Module\ModuleList\DeploymentConfig',
186-
[],
187-
[],
188-
'',
189-
false
190-
);
191-
$deploymentConfig->expects($this->any())->method('getData')->willReturn($modules);
192-
$deploymentConfigFactory->expects($this->any())->method('create')->with($modules)
193-
->willReturn($deploymentConfig);
194-
}
190+
195191
return new Installer(
196192
$this->filePermissions,
197193
$this->configWriter,
198194
$this->configReader,
199195
$this->config,
200-
$deploymentConfigFactory,
196+
$this->deploymentConfigFactory,
201197
$this->moduleList,
202-
$moduleLoader,
198+
$this->moduleLoader,
203199
$this->directoryList,
204200
$this->adminFactory,
205201
$this->logger,
@@ -227,7 +223,12 @@ public function testInstall()
227223
[DbConfig::CONFIG_KEY, self::$dbConfig],
228224
[EncryptConfig::CONFIG_KEY, [EncryptConfig::KEY_ENCRYPTION_KEY => 'encryption_key']]
229225
]));
230-
226+
$allModules = ['Foo_One' => [], 'Bar_Two' => []];
227+
$this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules);
228+
$modules = ['Foo_One' => 1, 'Bar_Two' => 1 ];
229+
$this->deploymentConfig->expects($this->any())->method('getData')->willReturn($modules);
230+
$this->deploymentConfigFactory->expects($this->any())->method('create')->with($modules)
231+
->willReturn($this->deploymentConfig);
231232
$setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false);
232233
$table = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false);
233234
$connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface');
@@ -311,40 +312,29 @@ public function testCheckApplicationFilePermissions()
311312
$this->assertSame(['message' => [$expectedMessage]], $this->object->getInstallInfo());
312313
}
313314

314-
public function testUpdateModulesInDeploymentConfig()
315+
public function testUpdateModulesSequence()
315316
{
316-
$moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false);
317317
$allModules = [
318318
'Foo_One' => [],
319319
'Bar_Two' => [],
320320
'New_Module' => [],
321321
];
322-
$moduleLoader->expects($this->once())->method('load')->willReturn($allModules);
322+
$this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules);
323323

324-
$deploymentConfigFactory = $this->getMock(
325-
'Magento\Framework\Module\ModuleList\DeploymentConfigFactory',
326-
[],
327-
[],
328-
'',
329-
false
330-
);
331324
$expectedModules = [
332325
'Bar_Two' => 0,
333326
'Foo_One' => 1,
334327
'New_Module' => 1
335328
];
336-
$deploymentConfig = $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfig', [], [], '', false);
337329

338-
$deploymentConfigFactory->expects($this->any())->method('create')->with($expectedModules)
339-
->willReturn($deploymentConfig);
330+
$this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules)
331+
->willReturn($this->deploymentConfig);
340332

341-
$newObject = $this->createObject(false, false, $moduleLoader, $deploymentConfigFactory);
333+
$newObject = $this->createObject(false, false);
342334
$this->configReader->expects($this->once())->method('load')
343335
->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0] ]);
344-
$deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules)
345-
->willReturn($deploymentConfig);
346-
$this->configWriter->expects($this->once())->method('update')->with($deploymentConfig);
347-
$newObject->updateModulesInDeploymentConfig();
336+
$this->configWriter->expects($this->once())->method('update')->with($this->deploymentConfig);
337+
$newObject->updateModulesSequence();
348338
}
349339

350340
public function testUninstall()

lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Magento\Framework\Module\ModuleList;
88

99
/**
10-
* Deployment configuration segment for modules
10+
* Factory for Deployment configuration segment for modules
1111
*/
1212
class DeploymentConfigFactory
1313
{

lib/internal/Magento/Framework/Module/Status.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Status
6060
private $conflictChecker;
6161

6262
/**
63-
* factory to create module deployment config object
63+
* Factory to create module deployment config object
6464
*
6565
* @var DeploymentConfigFactory
6666
*/

setup/src/Magento/Setup/Controller/ConsoleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ public function installDataAction()
405405
*/
406406
public function updateAction()
407407
{
408-
$this->installer->updateModulesInDeploymentConfig();
408+
$this->installer->updateModulesSequence();
409409
$this->installer->installSchema();
410410
$this->installer->installDataFixtures();
411411
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,11 @@ public function installAdminUser($data)
812812
*
813813
* @return void
814814
*/
815-
public function updateModulesInDeploymentConfig()
815+
public function updateModulesSequence()
816816
{
817817
$allModules = array_keys($this->moduleLoader->load());
818-
$currentModules = $this->deploymentConfigReader->load()['modules'] ;
818+
$deploymentConfig = $this->deploymentConfigReader->load();
819+
$currentModules = isset($deploymentConfig['modules']) ? $deploymentConfig['modules'] : [] ;
819820
$result = [];
820821
foreach ($allModules as $module) {
821822
if (isset($currentModules[$module]) && !$currentModules[$module]) {

0 commit comments

Comments
 (0)