public function testComponentsAction()
 {
     $objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface', [], [], '', false);
     $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
     $objectManager->expects($this->any())->method('get')->willReturnMap([['Magento\\Framework\\Module\\PackageInfoFactory', $this->packageInfoFactoryMock], ['Magento\\Framework\\Module\\FullModuleList', $this->fullModuleListMock], ['Magento\\Framework\\Module\\ModuleList', $this->enabledModuleListMock]]);
     $this->packageInfoFactoryMock->expects($this->once())->method('create')->willReturn($this->packageInfo);
     $this->fullModuleListMock->expects($this->once())->method('getNames')->willReturn(['magento/sample-module1']);
     $this->packageInfo->expects($this->once())->method('getModuleName')->willReturn('Sample_Module');
     $this->packageInfo->expects($this->exactly(2))->method('getPackageName')->willReturn($this->componentData['magento/sample-module-one']['name']);
     $this->packageInfo->expects($this->exactly(2))->method('getVersion')->willReturn($this->componentData['magento/sample-module-one']['version']);
     $this->enabledModuleListMock->expects($this->once())->method('has')->willReturn(true);
     $this->composerInformationMock->expects($this->once())->method('getInstalledMagentoPackages')->willReturn($this->componentData);
     $this->composerInformationMock->expects($this->once())->method('isPackageInComposerJson')->willReturn(true);
     $this->packagesAuth->expects($this->once())->method('getAuthJsonData')->willReturn(['username' => 'someusername', 'password' => 'somepassword']);
     $this->packagesData->expects($this->once())->method('syncPackagesData')->willReturn($this->lastSyncData);
     $jsonModel = $this->controller->componentsAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertTrue($variables['success']);
     $expected = [['name' => 'magento/sample-module-one', 'type' => 'magento2-module', 'version' => '1.0.0', 'update' => false, 'uninstall' => true, 'vendor' => 'magento', 'moduleName' => 'Sample_Module', 'enable' => true, 'disable' => false]];
     $this->assertEquals($expected, $variables['components']);
     $this->assertArrayHasKey('total', $variables);
     $this->assertEquals(1, $variables['total']);
     $this->assertEquals($this->lastSyncData, $variables['lastSyncData']);
 }
Esempio n. 2
0
 public function testComponentsAction()
 {
     $this->fullModuleListMock->expects($this->once())
         ->method('getNames')
         ->willReturn(['magento/sample-module1']);
     $this->packageInfo->expects($this->once())
         ->method('getModuleName')
         ->willReturn('Sample_Module');
     $this->packageInfo->expects($this->exactly(2))
         ->method('getPackageName')
         ->willReturn($this->componentData['magento/sample-module-one']['name']);
     $this->packageInfo->expects($this->exactly(2))
         ->method('getVersion')
         ->willReturn($this->componentData['magento/sample-module-one']['version']);
     $this->enabledModuleListMock->expects($this->once())
         ->method('has')
         ->willReturn(true);
     $this->composerInformationMock->expects($this->once())
         ->method('getInstalledMagentoPackages')
         ->willReturn($this->componentData);
     $this->composerInformationMock->expects($this->once())
         ->method('isPackageInComposerJson')
         ->willReturn(true);
     $this->updatePackagesCacheMock->expects($this->once())
         ->method('getPackagesForUpdate')
         ->willReturn($this->lastSyncData);
     $jsonModel = $this->controller->componentsAction();
     $this->assertInstanceOf('Zend\View\Model\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertTrue($variables['success']);
     $expected = [[
         'name' => 'magento/sample-module-one',
         'type' => 'magento2-module',
         'version' => '1.0.0',
         'update' => false,
         'uninstall' => true,
         'vendor' => 'magento',
         'moduleName' => 'Sample_Module',
         'enable' => true,
         'disable' => false
     ]];
     $this->assertEquals($expected, $variables['components']);
     $this->assertArrayHasKey('total', $variables);
     $this->assertEquals(1, $variables['total']);
     $this->assertEquals($this->lastSyncData, $variables['lastSyncData']);
 }