Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ModuleStatusCommandTest.php
Go to the documentation of this file.
1 <?php
7 
9 use Symfony\Component\Console\Tester\CommandTester;
10 
11 class ModuleStatusCommandTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testExecute()
14  {
15  $objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
16  $objectManager = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
17  $objectManagerProvider->expects($this->any())
18  ->method('get')
19  ->will($this->returnValue($objectManager));
20  $moduleList = $this->createMock(\Magento\Framework\Module\ModuleList::class);
21  $fullModuleList = $this->createMock(\Magento\Framework\Module\FullModuleList::class);
22  $objectManager->expects($this->any())
23  ->method('create')
24  ->will($this->returnValueMap([
25  [\Magento\Framework\Module\ModuleList::class, [], $moduleList],
26  [\Magento\Framework\Module\FullModuleList::class, [], $fullModuleList],
27  ]));
28  $moduleList->expects($this->any())
29  ->method('getNames')
30  ->will($this->returnValue(['Magento_Module1', 'Magento_Module2']));
31  $fullModuleList->expects($this->any())
32  ->method('getNames')
33  ->will($this->returnValue(['Magento_Module1', 'Magento_Module2', 'Magento_Module3']));
34  $commandTester = new CommandTester(new ModuleStatusCommand($objectManagerProvider));
35  $commandTester->execute([]);
36  $this->assertStringMatchesFormat(
37  'List of enabled modules%aMagento_Module1%aMagento_Module2%a'
38  . 'List of disabled modules%aMagento_Module3%a',
39  $commandTester->getDisplay()
40  );
41  }
42 }
$objectManager
Definition: bootstrap.php:17