@@ -47,6 +47,21 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
47
47
*/
48
48
private $ moduleList ;
49
49
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
+
50
65
/**
51
66
* @var \Magento\Framework\App\Filesystem\DirectoryList|\PHPUnit_Framework_MockObject_MockObject
52
67
*/
@@ -128,6 +143,21 @@ protected function setUp()
128
143
$ this ->moduleList ->expects ($ this ->any ())->method ('getNames ' )->willReturn (
129
144
['Foo_One ' , 'Bar_Two ' ]
130
145
);
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
+ );
131
161
$ this ->directoryList = $ this ->getMock ('Magento\Framework\App\Filesystem\DirectoryList ' , [], [], '' , false );
132
162
$ this ->adminFactory = $ this ->getMock ('Magento\Setup\Model\AdminAccountFactory ' , [], [], '' , false );
133
163
$ this ->logger = $ this ->getMockForAbstractClass ('Magento\Setup\Model\LoggerInterface ' );
@@ -146,16 +176,9 @@ protected function setUp()
146
176
*
147
177
* @param \PHPUnit_Framework_MockObject_MockObject|bool $connectionFactory
148
178
* @param \PHPUnit_Framework_MockObject_MockObject|bool $objectManagerProvider
149
- * @param \PHPUnit_Framework_MockObject_MockObject|bool $moduleLoader
150
- * @param \PHPUnit_Framework_MockObject_MockObject|bool $deploymentConfigFactory
151
179
* @return Installer
152
180
*/
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 ) {
159
182
if (!$ connectionFactory ) {
160
183
$ connectionFactory = $ this ->getMock ('Magento\Setup\Module\ConnectionFactory ' , [], [], '' , false );
161
184
$ connectionFactory ->expects ($ this ->any ())->method ('create ' )->willReturn ($ this ->connection );
@@ -164,42 +187,15 @@ private function createObject(
164
187
$ objectManagerProvider = $ this ->getMock ('Magento\Setup\Model\ObjectManagerProvider ' , [], [], '' , false );
165
188
$ objectManagerProvider ->expects ($ this ->any ())->method ('get ' )->willReturn ($ this ->objectManager );
166
189
}
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
+
195
191
return new Installer (
196
192
$ this ->filePermissions ,
197
193
$ this ->configWriter ,
198
194
$ this ->configReader ,
199
195
$ this ->config ,
200
- $ deploymentConfigFactory ,
196
+ $ this -> deploymentConfigFactory ,
201
197
$ this ->moduleList ,
202
- $ moduleLoader ,
198
+ $ this -> moduleLoader ,
203
199
$ this ->directoryList ,
204
200
$ this ->adminFactory ,
205
201
$ this ->logger ,
@@ -227,7 +223,12 @@ public function testInstall()
227
223
[DbConfig::CONFIG_KEY , self ::$ dbConfig ],
228
224
[EncryptConfig::CONFIG_KEY , [EncryptConfig::KEY_ENCRYPTION_KEY => 'encryption_key ' ]]
229
225
]));
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 );
231
232
$ setup = $ this ->getMock ('Magento\Setup\Module\Setup ' , [], [], '' , false );
232
233
$ table = $ this ->getMock ('Magento\Framework\DB\Ddl\Table ' , [], [], '' , false );
233
234
$ connection = $ this ->getMockForAbstractClass ('Magento\Framework\DB\Adapter\AdapterInterface ' );
@@ -311,40 +312,29 @@ public function testCheckApplicationFilePermissions()
311
312
$ this ->assertSame (['message ' => [$ expectedMessage ]], $ this ->object ->getInstallInfo ());
312
313
}
313
314
314
- public function testUpdateModulesInDeploymentConfig ()
315
+ public function testUpdateModulesSequence ()
315
316
{
316
- $ moduleLoader = $ this ->getMock ('Magento\Framework\Module\ModuleList\Loader ' , [], [], '' , false );
317
317
$ allModules = [
318
318
'Foo_One ' => [],
319
319
'Bar_Two ' => [],
320
320
'New_Module ' => [],
321
321
];
322
- $ moduleLoader ->expects ($ this ->once ())->method ('load ' )->willReturn ($ allModules );
322
+ $ this -> moduleLoader ->expects ($ this ->once ())->method ('load ' )->willReturn ($ allModules );
323
323
324
- $ deploymentConfigFactory = $ this ->getMock (
325
- 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory ' ,
326
- [],
327
- [],
328
- '' ,
329
- false
330
- );
331
324
$ expectedModules = [
332
325
'Bar_Two ' => 0 ,
333
326
'Foo_One ' => 1 ,
334
327
'New_Module ' => 1
335
328
];
336
- $ deploymentConfig = $ this ->getMock ('Magento\Framework\Module\ModuleList\DeploymentConfig ' , [], [], '' , false );
337
329
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 );
340
332
341
- $ newObject = $ this ->createObject (false , false , $ moduleLoader , $ deploymentConfigFactory );
333
+ $ newObject = $ this ->createObject (false , false );
342
334
$ this ->configReader ->expects ($ this ->once ())->method ('load ' )
343
335
->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 ();
348
338
}
349
339
350
340
public function testUninstall ()
0 commit comments