@@ -301,6 +301,37 @@ public function helpActionForLanguageCurrencyTimezoneDataProvider()
301
301
];
302
302
}
303
303
304
+ public function testHelpActionForModuleList ()
305
+ {
306
+ $ this ->request ->expects ($ this ->once ())->method ('getParam ' )->willReturn (ConsoleController::HELP_LIST_OF_MODULES );
307
+ $ moduleListMock = $ this ->getMock ('Magento\Framework\Module\ModuleList ' , [], [], '' , false );
308
+ $ moduleListMock
309
+ ->expects ($ this ->once ())
310
+ ->method ('getNames ' )
311
+ ->will ($ this ->returnValue (['Magento_Core ' , 'Magento_Store ' ]));
312
+ $ fullModuleListMock = $ this ->getMock ('Magento\Framework\Module\FullModuleList ' , [], [], '' , false );
313
+ $ fullModuleListMock
314
+ ->expects ($ this ->once ())
315
+ ->method ('getNames ' )
316
+ ->will ($ this ->returnValue (['Magento_Core ' , 'Magento_Store ' , 'Magento_Directory ' ]));
317
+ $ returnValueMap = [
318
+ [
319
+ 'Magento\Framework\Module\ModuleList ' ,
320
+ [],
321
+ $ moduleListMock ,
322
+ ],
323
+ [
324
+ 'Magento\Framework\Module\FullModuleList ' ,
325
+ [],
326
+ $ fullModuleListMock ,
327
+ ],
328
+ ];
329
+ $ this ->objectManager ->expects ($ this ->exactly (2 ))
330
+ ->method ('create ' )
331
+ ->will ($ this ->returnValueMap ($ returnValueMap ));
332
+ $ this ->controller ->helpAction ();
333
+ }
334
+
304
335
public function testHelpActionNoType ()
305
336
{
306
337
$ beginHelpString = "\n==-------------------== \n"
@@ -322,7 +353,7 @@ public function testHelpActionNoType()
322
353
public function testModuleAction ($ command , $ modules , $ isForce , $ expectedIsEnabled , $ expectedModules )
323
354
{
324
355
$ status = $ this ->getModuleActionMocks ($ command , $ modules , $ isForce , false );
325
- $ status ->expects ($ this ->once ())->method ('getUnchangedModules ' )->willReturn ([] );
356
+ $ status ->expects ($ this ->once ())->method ('getModulesToChange ' )->willReturn ($ expectedModules );
326
357
if (!$ isForce ) {
327
358
$ status ->expects ($ this ->once ())->method ('checkConstraints ' )->willReturn ([]);
328
359
}
@@ -346,6 +377,44 @@ public function moduleActionDataProvider()
346
377
];
347
378
}
348
379
380
+ /**
381
+ * @param string $command
382
+ * @param string $modules
383
+ * @param bool $isForce
384
+ * @param bool $expectedIsEnabled
385
+ * @param string[] $expectedModules
386
+ * @dataProvider moduleActionEnabledSuggestionMessageDataProvider
387
+ */
388
+ public function testModuleActionEnabledSuggestionMessage ($ command , $ modules , $ isForce , $ expectedIsEnabled , $ expectedModules )
389
+ {
390
+ $ status = $ this ->getModuleActionMocks ($ command , $ modules , $ isForce , false );
391
+ $ status ->expects ($ this ->once ())->method ('getModulesToChange ' )->willReturn ($ expectedModules );
392
+ if (!$ isForce ) {
393
+ $ status ->expects ($ this ->once ())->method ('checkConstraints ' )->willReturn ([]);
394
+ }
395
+ $ status ->expects ($ this ->once ())
396
+ ->method ('setIsEnabled ' )
397
+ ->with ($ expectedIsEnabled , $ expectedModules );
398
+ $ this ->consoleLogger ->expects ($ this ->once ())
399
+ ->method ('log ' )
400
+ ->with ($ this ->stringContains (
401
+ "To make sure that the enabled modules are properly registered, run 'update' command. "
402
+ ));
403
+ $ this ->controller ->moduleAction ();
404
+ }
405
+
406
+ /**
407
+ * @return array
408
+ */
409
+ public function moduleActionEnabledSuggestionMessageDataProvider ()
410
+ {
411
+ return [
412
+ [ConsoleController::CMD_MODULE_ENABLE , 'Module_Foo,Module_Bar ' , false , true , ['Module_Foo ' , 'Module_Bar ' ]],
413
+ [ConsoleController::CMD_MODULE_ENABLE , 'Module_Foo,Module_Bar ' , true , true , ['Module_Foo ' , 'Module_Bar ' ]],
414
+ [ConsoleController::CMD_MODULE_ENABLE , 'Module_Foo,Module_Bar ' , false , true , ['Module_Foo ' ]],
415
+ ];
416
+ }
417
+
349
418
/**
350
419
* @param string $command
351
420
* @param string $modules
@@ -358,9 +427,9 @@ public function testModuleActionNoChanges($command, $modules, $isForce, $expecte
358
427
{
359
428
$ status = $ this ->getModuleActionMocks ($ command , $ modules , $ isForce , true );
360
429
$ status ->expects ($ this ->once ())
361
- ->method ('getUnchangedModules ' )
430
+ ->method ('getModulesToChange ' )
362
431
->with ($ expectedIsEnabled , $ expectedModules )
363
- ->willReturn ($ expectedModules );
432
+ ->willReturn ([] );
364
433
$ status ->expects ($ this ->never ())->method ('checkConstraints ' );
365
434
$ status ->expects ($ this ->never ())->method ('setIsEnabled ' );
366
435
$ this ->consoleLogger ->expects ($ this ->once ())->method ('log ' );
@@ -373,7 +442,7 @@ public function testModuleActionNoChanges($command, $modules, $isForce, $expecte
373
442
* @param bool $isForce
374
443
* @param bool $expectedIsEnabled
375
444
* @param string[] $expectedModules
376
- * @param string[] $unchangedModules
445
+ * @param string[] $modulesToChange
377
446
* @dataProvider moduleActionPartialNoChangesDataProvider
378
447
*/
379
448
public function testModuleActionPartialNoChanges (
@@ -382,16 +451,16 @@ public function testModuleActionPartialNoChanges(
382
451
$ isForce ,
383
452
$ expectedIsEnabled ,
384
453
$ expectedModules ,
385
- $ unchangedModules
454
+ $ modulesToChange
386
455
) {
387
456
$ status = $ this ->getModuleActionMocks ($ command , $ modules , $ isForce , false );
388
- $ status ->expects ($ this ->once ())->method ('getUnchangedModules ' )->willReturn ($ unchangedModules );
457
+ $ status ->expects ($ this ->once ())->method ('getModulesToChange ' )->willReturn ($ modulesToChange );
389
458
if (!$ isForce ) {
390
459
$ status ->expects ($ this ->once ())->method ('checkConstraints ' )->willReturn ([]);
391
460
}
392
461
$ status ->expects ($ this ->once ())
393
462
->method ('setIsEnabled ' )
394
- ->with ($ expectedIsEnabled , array_diff ( $ expectedModules , $ unchangedModules ) );
463
+ ->with ($ expectedIsEnabled , $ modulesToChange );
395
464
$ this ->consoleLogger ->expects ($ this ->once ())->method ('log ' );
396
465
$ this ->controller ->moduleAction ();
397
466
}
@@ -408,31 +477,31 @@ public function moduleActionPartialNoChangesDataProvider()
408
477
false ,
409
478
true ,
410
479
['Module_Foo ' , 'Module_Bar ' ],
411
- ['Module_Foo ' ],
480
+ ['Module_Bar ' ],
412
481
],
413
482
[
414
483
ConsoleController::CMD_MODULE_ENABLE ,
415
484
'Module_Foo,Module_Bar ' ,
416
485
true ,
417
486
true ,
418
487
['Module_Foo ' , 'Module_Bar ' ],
419
- ['Module_Foo ' ],
488
+ ['Module_Bar ' ],
420
489
],
421
490
[
422
491
ConsoleController::CMD_MODULE_DISABLE ,
423
492
'Module_Foo,Module_Bar ' ,
424
493
false ,
425
494
false ,
426
495
['Module_Foo ' , 'Module_Bar ' ],
427
- ['Module_Foo ' ],
496
+ ['Module_Bar ' ],
428
497
],
429
498
[
430
499
ConsoleController::CMD_MODULE_DISABLE ,
431
500
'Module_Foo,Module_Bar ' ,
432
501
true ,
433
502
false ,
434
503
['Module_Foo ' , 'Module_Bar ' ],
435
- ['Module_Foo ' ],
504
+ ['Module_Bar ' ],
436
505
],
437
506
];
438
507
}
@@ -472,7 +541,7 @@ public function testModuleActionNotAllowed()
472
541
false ,
473
542
false
474
543
);
475
- $ status ->expects ($ this ->once ())->method ('getUnchangedModules ' )->willReturn ([]);
544
+ $ status ->expects ($ this ->once ())->method ('getModulesToChange ' )->willReturn ([' Module_Foo ' , ' Module_Bar ' ]);
476
545
$ status ->expects ($ this ->once ())
477
546
->method ('checkConstraints ' )
478
547
->willReturn (['Circular dependency of Foo and Bar ' ]);
0 commit comments