@@ -32,6 +32,11 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
32
32
*/
33
33
private $ configWriter ;
34
34
35
+ /**
36
+ * @var \Magento\Framework\App\DeploymentConfig\Reader|\PHPUnit_Framework_MockObject_MockObject
37
+ */
38
+ private $ configReader ;
39
+
35
40
/**
36
41
* @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject
37
42
*/
@@ -42,11 +47,6 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
42
47
*/
43
48
private $ moduleList ;
44
49
45
- /**
46
- * @var \Magento\Framework\Module\ModuleList\Loader|\PHPUnit_Framework_MockObject_MockObject
47
- */
48
- private $ moduleLoader ;
49
-
50
50
/**
51
51
* @var \Magento\Framework\App\Filesystem\DirectoryList|\PHPUnit_Framework_MockObject_MockObject
52
52
*/
@@ -118,6 +118,7 @@ protected function setUp()
118
118
{
119
119
$ this ->filePermissions = $ this ->getMock ('Magento\Setup\Model\FilePermissions ' , [], [], '' , false );
120
120
$ this ->configWriter = $ this ->getMock ('Magento\Framework\App\DeploymentConfig\Writer ' , [], [], '' , false );
121
+ $ this ->configReader = $ this ->getMock ('Magento\Framework\App\DeploymentConfig\Reader ' , [], [], '' , false );
121
122
$ this ->config = $ this ->getMock ('Magento\Framework\App\DeploymentConfig ' , [], [], '' , false );
122
123
123
124
$ this ->moduleList = $ this ->getMockForAbstractClass ('Magento\Framework\Module\ModuleListInterface ' );
@@ -127,12 +128,6 @@ protected function setUp()
127
128
$ this ->moduleList ->expects ($ this ->any ())->method ('getNames ' )->willReturn (
128
129
['Foo_One ' , 'Bar_Two ' ]
129
130
);
130
- $ this ->moduleLoader = $ this ->getMock ('Magento\Framework\Module\ModuleList\Loader ' , [], [], '' , false );
131
- $ allModules = [
132
- 'Foo_One ' => [],
133
- 'Bar_Two ' => [],
134
- ];
135
- $ this ->moduleLoader ->expects ($ this ->any ())->method ('load ' )->willReturn ($ allModules );
136
131
$ this ->directoryList = $ this ->getMock ('Magento\Framework\App\Filesystem\DirectoryList ' , [], [], '' , false );
137
132
$ this ->adminFactory = $ this ->getMock ('Magento\Setup\Model\AdminAccountFactory ' , [], [], '' , false );
138
133
$ this ->logger = $ this ->getMockForAbstractClass ('Magento\Setup\Model\LoggerInterface ' );
@@ -151,10 +146,16 @@ protected function setUp()
151
146
*
152
147
* @param \PHPUnit_Framework_MockObject_MockObject|bool $connectionFactory
153
148
* @param \PHPUnit_Framework_MockObject_MockObject|bool $objectManagerProvider
149
+ * @param \PHPUnit_Framework_MockObject_MockObject|bool $moduleLoader
150
+ * @param \PHPUnit_Framework_MockObject_MockObject|bool $deploymentConfigFactory
154
151
* @return Installer
155
152
*/
156
- private function createObject ($ connectionFactory = false , $ objectManagerProvider = false )
157
- {
153
+ private function createObject (
154
+ $ connectionFactory = false ,
155
+ $ objectManagerProvider = false ,
156
+ $ moduleLoader = false ,
157
+ $ deploymentConfigFactory = false
158
+ ) {
158
159
if (!$ connectionFactory ) {
159
160
$ connectionFactory = $ this ->getMock ('Magento\Setup\Module\ConnectionFactory ' , [], [], '' , false );
160
161
$ connectionFactory ->expects ($ this ->any ())->method ('create ' )->willReturn ($ this ->connection );
@@ -163,12 +164,42 @@ private function createObject($connectionFactory = false, $objectManagerProvider
163
164
$ objectManagerProvider = $ this ->getMock ('Magento\Setup\Model\ObjectManagerProvider ' , [], [], '' , false );
164
165
$ objectManagerProvider ->expects ($ this ->any ())->method ('get ' )->willReturn ($ this ->objectManager );
165
166
}
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
+ }
166
195
return new Installer (
167
196
$ this ->filePermissions ,
168
197
$ this ->configWriter ,
198
+ $ this ->configReader ,
169
199
$ this ->config ,
200
+ $ deploymentConfigFactory ,
170
201
$ this ->moduleList ,
171
- $ this -> moduleLoader ,
202
+ $ moduleLoader ,
172
203
$ this ->directoryList ,
173
204
$ this ->adminFactory ,
174
205
$ this ->logger ,
@@ -280,6 +311,42 @@ public function testCheckApplicationFilePermissions()
280
311
$ this ->assertSame (['message ' => [$ expectedMessage ]], $ this ->object ->getInstallInfo ());
281
312
}
282
313
314
+ public function testUpdateModulesInDeploymentConfig ()
315
+ {
316
+ $ moduleLoader = $ this ->getMock ('Magento\Framework\Module\ModuleList\Loader ' , [], [], '' , false );
317
+ $ allModules = [
318
+ 'Foo_One ' => [],
319
+ 'Bar_Two ' => [],
320
+ 'New_Module ' => [],
321
+ ];
322
+ $ moduleLoader ->expects ($ this ->once ())->method ('load ' )->willReturn ($ allModules );
323
+
324
+ $ deploymentConfigFactory = $ this ->getMock (
325
+ 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory ' ,
326
+ [],
327
+ [],
328
+ '' ,
329
+ false
330
+ );
331
+ $ expectedModules = [
332
+ 'Bar_Two ' => 0 ,
333
+ 'Foo_One ' => 1 ,
334
+ 'New_Module ' => 1
335
+ ];
336
+ $ deploymentConfig = $ this ->getMock ('Magento\Framework\Module\ModuleList\DeploymentConfig ' , [], [], '' , false );
337
+
338
+ $ deploymentConfigFactory ->expects ($ this ->any ())->method ('create ' )->with ($ expectedModules )
339
+ ->willReturn ($ deploymentConfig );
340
+
341
+ $ newObject = $ this ->createObject (false , false , $ moduleLoader , $ deploymentConfigFactory );
342
+ $ this ->configReader ->expects ($ this ->once ())->method ('load ' )
343
+ ->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 ();
348
+ }
349
+
283
350
public function testUninstall ()
284
351
{
285
352
$ this ->config ->expects ($ this ->once ())->method ('isAvailable ' )->willReturn (false );
0 commit comments