/**
  * @param array $packageList
  * @param string $expectedVersion
  * @dataProvider testGetVersionGitInstallationDataProvider
  */
 public function testGetVersion($packageList, $expectedVersion)
 {
     $this->composerInformationMock->expects($this->any())->method('getSystemPackages')->willReturn($packageList);
     $productVersion = $this->productMetadata->getVersion();
     $this->assertNotEmpty($productVersion, 'Empty product version');
     $this->assertEquals($expectedVersion, $productVersion);
 }
 public function testComponentsActionWithError()
 {
     $this->composerInformation->expects($this->once())->method('getInstalledMagentoPackages')->will($this->throwException(new \Exception("Test error message")));
     $jsonModel = $this->controller->componentsAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('responseType', $variables);
     $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']);
 }
 public function testRunUninstallReadinessCheckWithError()
 {
     $packages = ['verndor/module' => 'magento2-module', 'verndor/theme' => 'magento2-theme', 'verndor/metapackage' => 'metapackage', 'verndor/language' => 'magento2-language'];
     $this->composerInfo->expects($this->once())->method('getRootRequiredPackageTypesByName')->willReturn($packages);
     $this->packageDependencyChecker->expects($this->once())->method('checkDependencies')->with(array_keys($packages))->willReturn([]);
     $this->themeDependencyChecker->expects($this->once())->method('checkChildThemeByPackagesName')->with(['verndor/theme'])->willReturn(['Error message']);
     $result = $this->uninstallDependencyCheck->runUninstallReadinessCheck(array_keys($packages));
     $this->assertEquals(['success' => false, 'error' => 'Error message'], $result);
 }
示例#4
0
 /**
  * @covers \Magento\Setup\Controller\Connect::saveAuthJsonAction
  */
 public function testSaveAuthJsonActionWithError()
 {
     $this->connectManager->expects($this->once())->method('checkCredentialsAction')->will($this->throwException(new \Exception()));
     $this->composerInformation->expects($this->never())->method('saveAuthJson');
     $jsonModel = $this->controller->saveAuthJsonAction();
     $this->assertInstanceOf('\\Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertArrayHasKey('message', $variables);
     $this->assertFalse($variables['success']);
 }
 public function testCheckPhpExtensionsFailed()
 {
     $this->composerInfo->expects($this->once())->method('getRequiredExtensions')->willReturn(['a', 'b', 'c']);
     $this->phpInfo->expects($this->once())->method('getCurrent')->willReturn(['a', 'b']);
     $expected = ['responseType' => ResponseTypeInterface::RESPONSE_TYPE_ERROR, 'data' => ['required' => ['a', 'b', 'c'], 'missing' => ['c']]];
     $this->assertEquals($expected, $this->phpReadinessCheck->checkPhpExtensions());
 }
    /**
     * @param string $ceCurrentVersion
     * @param array $expectedResult
     *
     * @dataProvider getAllowedEnterpriseVersionsDataProvider
     */
    public function testGetAllowedEnterpriseVersions($ceCurrentVersion, $expectedResult)
    {
        $this->composerAppFactory->expects($this->once())
            ->method('createInfoCommand')
            ->willReturn($this->infoCommand);
        $this->systemPackage = new SystemPackage($this->composerAppFactory, $this->composerInformation);
        $this->infoCommand->expects($this->once())
            ->method('run')
            ->with('magento/product-enterprise-edition')
            ->willReturn(['available_versions' => ['1.0.0', '1.0.1', '1.0.2']]);
        $require = $this->getMock('\Composer\Package\Link', [], [], '', false);
        $constraintMock = $this->getMock('\Composer\Package\LinkConstraint\VersionConstraint', [], [], '', false);
        $constraintMock->expects($this->any())->method('getPrettyString')
            ->willReturn('1.0.1');
        $require->expects($this->any())
            ->method('getConstraint')
            ->willReturn($constraintMock);

        $this->composerInformation->expects($this->any())
            ->method('getPackageRequirements')
            ->willReturn(['magento/product-community-edition' => $require]);
        $this->assertEquals(
            $expectedResult,
            $this->systemPackage->getAllowedEnterpriseVersions($ceCurrentVersion)
        );
    }
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage error
  */
 public function testExecuteUpdateFails()
 {
     $this->updater->expects($this->once())->method('createUpdaterTask')->willReturn('error');
     $this->composerInformation->expects($this->once())->method('getInstalledMagentoPackages')->willReturn(['vendor/language-a' => ['type' => JobComponentUninstall::COMPONENT_LANGUAGE]]);
     $this->job = new JobComponentUninstall($this->composerInformation, $this->moduleUninstallHelper, $this->themeUninstallHelper, $this->objectManagerProvider, $this->output, $this->quence, $this->status, $this->updater, 'setup:component:uninstall', ['components' => [[JobComponentUninstall::COMPONENT_NAME => 'vendor/language-a']]]);
     $this->job->execute();
 }
 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 testExecutePackageNoLanguage()
 {
     $dependencies['vendor/language-ua_ua'] = [];
     $this->dependencyChecker->expects($this->once())->method('checkDependencies')->with(['vendor/language-ua_ua'])->willReturn($dependencies);
     $this->composerInfo->expects($this->once())->method('getRootRequiredPackagesAndTypes')->willReturn(['vendor/language-ua_ua' => 'library']);
     $this->remove->expects($this->never())->method('remove');
     $this->cache->expects($this->never())->method('clean');
     $this->tester->execute(['package' => ['vendor/language-ua_ua']]);
     $this->assertContains('Package vendor/language-ua_ua is not a Magento language and will be skipped', $this->tester->getDisplay());
     $this->assertContains('Nothing is removed.', $this->tester->getDisplay());
 }
示例#10
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']);
 }