/**
  * Constructor
  *
  * @param ModuleList $list
  * @param ModuleList\Loader $loader
  * @param PackageInfoFactory $packageInfoFactory
  */
 public function __construct(ModuleList $list, ModuleList\Loader $loader, PackageInfoFactory $packageInfoFactory)
 {
     $this->enabledModuleList = $list->getNames();
     $this->fullModuleList = $loader->load();
     $packageInfo = $packageInfoFactory->create();
     $this->graph = $this->createGraph($packageInfo);
 }
예제 #2
0
 /**
  * Perform setup side uninstall
  *
  * @param OutputInterface $output
  * @param string $componentName
  * @param bool $dataOption
  * @return void
  */
 public function uninstall(OutputInterface $output, $componentName, $dataOption)
 {
     $packageInfo = $this->packageInfoFactory->create();
     // convert to module name
     $moduleName = $packageInfo->getModuleName($componentName);
     if ($dataOption) {
         $this->moduleUninstaller->uninstallData($output, [$moduleName]);
     }
     $this->moduleRegistryUninstaller->removeModulesFromDb($output, [$moduleName]);
     $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($output, [$moduleName]);
 }
 public function testCreate()
 {
     $fullModuleList = $this->getMock('Magento\\Framework\\Module\\FullModuleList', [], [], '', false);
     $reader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false);
     $packageInfo = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $returnValueMap = [['Magento\\Framework\\Module\\FullModuleList', [], $fullModuleList], ['Magento\\Framework\\Module\\Dir\\Reader', ['moduleList' => $fullModuleList], $reader], ['Magento\\Framework\\Module\\PackageInfo', ['reader' => $reader], $packageInfo]];
     $objectManagerMock = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface');
     $objectManagerMock->expects($this->any())->method('create')->will($this->returnValueMap($returnValueMap));
     $factory = new PackageInfoFactory($objectManagerMock);
     $this->assertSame($packageInfo, $factory->create());
 }
 protected function setUp()
 {
     $this->packageInfoMock = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $requireMap = [['A', ['B']], ['B', ['D', 'E']], ['C', ['E']], ['D', ['A']], ['E', []]];
     $this->packageInfoMock->expects($this->any())->method('getRequire')->will($this->returnValueMap($requireMap));
     $this->packageInfoFactoryMock = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false);
     $this->packageInfoFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->packageInfoMock));
     $this->listMock = $this->getMock('Magento\\Framework\\Module\\ModuleList', [], [], '', false);
     $this->loaderMock = $this->getMock('Magento\\Framework\\Module\\ModuleList\\Loader', [], [], '', false);
     $this->loaderMock->expects($this->any())->method('load')->will($this->returnValue(['A' => [], 'B' => [], 'C' => [], 'D' => [], 'E' => []]));
 }
예제 #5
0
 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']);
 }
 public function setUp()
 {
     $this->convertedLastSyncDate = ['lastSyncDate' => ['date' => self::FORMATTED_DATE, 'time' => self::FORMATTED_TIME]];
     $this->lastSyncData = ["lastSyncDate" => "1447271496", "packages" => ['magento/sample-module-one' => ['name' => 'magento/sample-module-one', 'type' => 'magento2-module', 'version' => '1.0.0']], 'countOfInstall' => 0, 'countOfUpdate' => 1];
     $this->componentData = ['magento/sample-module-one' => ['name' => 'magento/sample-module-one', 'type' => 'magento2-module', 'version' => '1.0.0']];
     $allComponentData = ['magento/sample-module-two' => ['name' => 'magento/sample-module-two', 'type' => 'magento2-module', 'version' => '1.0.0']];
     $allComponentData = array_merge($allComponentData, $this->componentData);
     $this->composerInformationMock = $this->getMock('Magento\\Framework\\Composer\\ComposerInformation', [], [], '', false);
     /** @var ObjectManagerProvider|\PHPUnit_Framework_MockObject_MockObject $objectManagerProvider */
     $objectManagerProvider = $this->getMock('Magento\\Setup\\Model\\ObjectManagerProvider', [], [], '', false);
     $objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface', [], [], '', false);
     $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
     $this->packageInfoFactoryMock = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false);
     $this->enabledModuleListMock = $this->getMock('Magento\\Framework\\Module\\ModuleList', [], [], '', false);
     $this->enabledModuleListMock->expects($this->any())->method('has')->willReturn(true);
     $this->fullModuleListMock = $this->getMock('Magento\\Framework\\Module\\FullModuleList', [], [], '', false);
     $this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allComponentData);
     $this->timezoneMock = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface', [], [], '', false);
     $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], ['Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface', $this->timezoneMock]]);
     /** @var TimezoneProvider|\PHPUnit_Framework_MockObject_MockObject $timezoneProviderMock */
     $timezoneProviderMock = $this->getMock('\\Magento\\Setup\\Model\\DateTime\\TimezoneProvider', [], [], '', false);
     $timezoneProviderMock->expects($this->any())->method('get')->willReturn($this->timezoneMock);
     $this->packageInfo = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $this->updatePackagesCacheMock = $this->getMock('Magento\\Setup\\Model\\UpdatePackagesCache', [], [], '', false);
     $this->marketplaceManagerMock = $this->getMock('Magento\\Setup\\Model\\MarketplaceManager', [], [], '', false);
     $this->packageInfoFactoryMock->expects($this->once())->method('create')->willReturn($this->packageInfo);
     $this->controller = new ComponentGrid($this->composerInformationMock, $objectManagerProvider, $this->updatePackagesCacheMock, $this->marketplaceManagerMock);
     $this->controller->setTimezone($timezoneProviderMock->get());
 }
 public function setUp()
 {
     $this->lastSyncData = ["lastSyncDate" => "2015/08/10 21:05:34", "packages" => ['magento/sample-module-one' => ['name' => 'magento/sample-module-one', 'type' => 'magento2-module', 'version' => '1.0.0']], 'countOfInstall' => 0, 'countOfUpdate' => 1];
     $this->componentData = ['magento/sample-module-one' => ['name' => 'magento/sample-module-one', 'type' => 'magento2-module', 'version' => '1.0.0']];
     $allComponentData = ['magento/sample-module-two' => ['name' => 'magento/sample-module-two', 'type' => 'magento2-module', 'version' => '1.0.0']];
     $allComponentData = array_merge($allComponentData, $this->componentData);
     $this->composerInformationMock = $this->getMock('Magento\\Framework\\Composer\\ComposerInformation', [], [], '', false);
     $objectManagerProvider = $this->getMock('Magento\\Setup\\Model\\ObjectManagerProvider', [], [], '', false);
     $objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface', [], [], '', false);
     $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
     $this->packageInfoFactoryMock = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false);
     $this->enabledModuleListMock = $this->getMock('Magento\\Framework\\Module\\ModuleList', [], [], '', false);
     $this->enabledModuleListMock->expects($this->any())->method('has')->willReturn(true);
     $this->fullModuleListMock = $this->getMock('Magento\\Framework\\Module\\FullModuleList', [], [], '', false);
     $this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allComponentData);
     $objectManager->expects($this->exactly(3))->method('get')->willReturnMap([['Magento\\Framework\\Module\\PackageInfoFactory', $this->packageInfoFactoryMock], ['Magento\\Framework\\Module\\FullModuleList', $this->fullModuleListMock], ['Magento\\Framework\\Module\\ModuleList', $this->enabledModuleListMock]]);
     $this->packageInfo = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $this->updatePackagesCacheMock = $this->getMock('Magento\\Setup\\Model\\UpdatePackagesCache', [], [], '', false);
     $this->connectManagerMock = $this->getMock('Magento\\Setup\\Model\\ConnectManager', [], [], '', false);
     $this->packageInfoFactoryMock->expects($this->once())->method('create')->willReturn($this->packageInfo);
     $this->controller = new ComponentGrid($this->composerInformationMock, $objectManagerProvider, $this->updatePackagesCacheMock, $this->connectManagerMock);
 }
 /**
  * Constructor
  *
  * @param ModuleList $list
  * @param PackageInfoFactory $packageInfoFactory
  */
 public function __construct(ModuleList $list, PackageInfoFactory $packageInfoFactory)
 {
     $this->list = $list;
     $this->packageInfo = $packageInfoFactory->create();
 }
예제 #9
0
 /**
  * Constructor
  *
  * @param \Magento\Backend\Block\Template\Context $context
  * @param \Magento\Framework\Module\PackageInfoFactory $packageInfoFactory
  */
 public function __construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Module\PackageInfoFactory $packageInfoFactory)
 {
     parent::__construct($context);
     $this->packageInfo = $packageInfoFactory->create();
 }