public function testCheckDependenciesWhenEnableModulesWithCurEnabledModules() { $this->packageInfoMock->expects($this->atLeastOnce())->method('getNonExistingDependencies')->willReturn([]); $this->checker = new DependencyChecker($this->listMock, $this->loaderMock, $this->packageInfoFactoryMock); $actual = $this->checker->checkDependenciesWhenEnableModules(['B', 'D'], ['C']); $expected = ['B' => ['A' => ['B', 'D', 'A'], 'E' => ['B', 'E']], 'D' => ['A' => ['D', 'A'], 'E' => ['D', 'A', 'B', 'E']]]; $this->assertEquals($expected, $actual); }
public 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' => []])); }
private function setUpPassValidation() { $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true); $packageMap = [['Magento_A', 'magento/package-a'], ['Magento_B', 'magento/package-b']]; $this->packageInfo->expects($this->any())->method('getPackageName')->will($this->returnValueMap($packageMap)); $this->fullModuleList->expects($this->any())->method('has')->willReturn(true); }
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 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']); }