public function testExecute() { $this->moduleList->expects($this->once())->method('getNames')->willReturn([]); $commandTester = new CommandTester($this->command); $commandTester->execute([]); $this->assertContains('List of active modules', $commandTester->getDisplay()); }
protected function setUp() { $this->filePermissions = $this->getMock('Magento\Framework\Setup\FilePermissions', [], [], '', false); $this->configWriter = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); $this->configReader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); $this->moduleList->expects($this->any())->method('getOne')->willReturn( ['setup_version' => '2.0.0'] ); $this->moduleList->expects($this->any())->method('getNames')->willReturn( ['Foo_One', 'Bar_Two'] ); $this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); $this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false); $this->logger = $this->getMockForAbstractClass('Magento\Framework\Setup\LoggerInterface'); $this->random = $this->getMock('Magento\Framework\Math\Random', [], [], '', false); $this->connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); $this->maintenanceMode = $this->getMock('Magento\Framework\App\MaintenanceMode', [], [], '', false); $this->filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); $this->contextMock = $this->getMock('Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); $this->configModel = $this->getMock('Magento\Setup\Model\ConfigModel', [], [], '', false); $this->cleanupFiles = $this->getMock('Magento\Framework\App\State\CleanupFiles', [], [], '', false); $this->dbValidator = $this->getMock('Magento\Setup\Validator\DbValidator', [], [], '', false); $this->setupFactory = $this->getMock('Magento\Setup\Module\SetupFactory', [], [], '', false); $this->dataSetupFactory = $this->getMock('Magento\Setup\Module\DataSetupFactory', [], [], '', false); $this->sampleDataState = $this->getMock('Magento\Framework\Setup\SampleData\State', [], [], '', false); $this->componentRegistrar = $this->getMock('Magento\Framework\Component\ComponentRegistrar', [], [], '', false); $this->phpReadinessCheck = $this->getMock('Magento\Setup\Model\PhpReadinessCheck', [], [], '', false); $this->object = $this->createObject(); }
/** * Tests modules data returns array and saving in DB * * @dataProvider itemDataProvider * @return void */ public function testGetModuleDataRefreshOrStatement($data) { $moduleCollectionMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\ResourceModel\\Module\\Collection')->disableOriginalConstructor()->getMock(); /** @var \Magento\NewRelicReporting\Model\Module|\PHPUnit_Framework_MockObject_MockObject $itemMock */ $itemMock = $this->getMock('Magento\\NewRelicReporting\\Model\\Module', ['getName', 'getData', 'setData', 'getState', 'save'], [], '', false); $modulesMockArray = ['Module_Name1' => ['name' => 'Module_Name1', 'setup_version' => '2.0.0', 'sequence' => []]]; $itemMock->setData($data); $testChangesMockArray = ['entity_id' => '3', 'name' => 'Name', 'active' => 'false', 'state' => 'enabled', 'setup_version' => '2.0.0', 'some_param' => 'some_value', 'updated_at' => '2015-09-02 18:38:17']; $itemMockArray = [$itemMock]; $enabledModulesMockArray = ['Module_Name2']; $allModulesMockArray = ['Module_Name1', 'Module_Name2']; $this->moduleCollectionFactoryMock->expects($this->any())->method('create')->willReturn($moduleCollectionMock); $this->moduleFactoryMock->expects($this->any())->method('create')->willReturn($itemMock); $itemMock->expects($this->any())->method('setData')->willReturnSelf(); $itemMock->expects($this->any())->method('save')->willReturnSelf(); $itemMock->expects($this->any())->method('getState')->willReturn($data['state']); $itemMock->expects($this->any())->method('getName')->willReturn($data['name']); $moduleCollectionMock->expects($this->any())->method('getItems')->willReturn($itemMockArray); $itemMock->expects($this->any())->method('getData')->willReturn($testChangesMockArray); $this->fullModuleListMock->expects($this->once())->method('getAll')->willReturn($modulesMockArray); $this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allModulesMockArray); $this->moduleListMock->expects($this->any())->method('getNames')->willReturn($enabledModulesMockArray); $this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(true)); $this->assertInternalType('array', $this->model->getModuleData()); }
protected function setUp() { $this->filePermissions = $this->getMock('Magento\\Setup\\Model\\FilePermissions', [], [], '', false); $this->configWriter = $this->getMock('Magento\\Framework\\App\\DeploymentConfig\\Writer', [], [], '', false); $this->configReader = $this->getMock('Magento\\Framework\\App\\DeploymentConfig\\Reader', [], [], '', false); $this->config = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false); $this->moduleList = $this->getMockForAbstractClass('Magento\\Framework\\Module\\ModuleListInterface'); $this->moduleList->expects($this->any())->method('getOne')->willReturn(['setup_version' => '2.0.0']); $this->moduleList->expects($this->any())->method('getNames')->willReturn(['Foo_One', 'Bar_Two']); $this->moduleLoader = $this->getMock('Magento\\Framework\\Module\\ModuleList\\Loader', [], [], '', false); $this->deploymentConfigFactory = $this->getMock('Magento\\Framework\\Module\\ModuleList\\DeploymentConfigFactory', [], [], '', false); $this->deploymentConfig = $this->getMock('Magento\\Framework\\Module\\ModuleList\\DeploymentConfig', [], [], '', false); $this->directoryList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false); $this->adminFactory = $this->getMock('Magento\\Setup\\Model\\AdminAccountFactory', [], [], '', false); $this->logger = $this->getMockForAbstractClass('Magento\\Setup\\Model\\LoggerInterface'); $this->random = $this->getMock('Magento\\Framework\\Math\\Random', [], [], '', false); $this->connection = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Adapter\\AdapterInterface'); $this->maintenanceMode = $this->getMock('Magento\\Framework\\App\\MaintenanceMode', [], [], '', false); $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false); $this->sampleData = $this->getMock('Magento\\Setup\\Model\\SampleData', [], [], '', false); $this->objectManager = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface'); $this->contextMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false); $this->object = $this->createObject(); }
/** * @param string $path * @param string $expectedResult * @dataProvider getModuleNameDataProvider */ public function testGetModuleName($path, $expectedResult) { $this->_moduleList->expects($this->once())->method('getNames')->will($this->returnValue(['Fixture_ModuleOne', 'Fixture_ModuleTwo'])); $this->_moduleDirs->expects($this->atLeastOnce())->method('getDir')->will($this->returnValueMap([['Fixture_ModuleOne', '', 'app/code/Fixture/ModuleOne'], ['Fixture_ModuleTwo', '', 'app/code/Fixture/ModuleTwo']])); $this->assertSame($expectedResult, $this->_model->getModuleName($path)); }
/** * @param string $namespace * @param array $modules * @param string $expected * @param bool $asFullModuleName * * @dataProvider determineOmittedNamespaceDataProvider */ public function testDetermineOmittedNamespace($namespace, $modules, $expected, $asFullModuleName) { $this->moduleListMock->expects($this->once())->method('getNames')->willReturn($modules); $this->assertSame($expected, $this->namespaceResolver->determineOmittedNamespace($namespace, $asFullModuleName)); }