示例#1
0
 public function testRemove()
 {
     $composerAppFactory = $this->getMock('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory', [], [], '', false);
     $composerApp = $this->getMock('Magento\\Composer\\MagentoComposerApplication', [], [], '', false);
     $composerApp->expects($this->once())->method('runComposerCommand');
     $composerAppFactory->expects($this->once())->method('create')->willReturn($composerApp);
     $remove = new Remove($composerAppFactory);
     $remove->remove(['magento/package-a', 'magento/package-b']);
 }
 /**
  * Uninstall theme from code base
  *
  * @param OutputInterface $output
  * @param array $themePaths
  * @return void
  */
 public function uninstallCode(OutputInterface $output, array $themePaths)
 {
     $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from Magento codebase');
     $packageNames = [];
     foreach ($themePaths as $themePath) {
         $packageNames[] = $this->themePackageInfo->getPackageName($themePath);
     }
     $output->writeln($this->remove->remove($packageNames));
 }
 public function testUninstallCode()
 {
     $this->output->expects($this->atLeastOnce())->method('writeln');
     $this->themePackageInfo->expects($this->at(0))->method('getPackageName')->willReturn('packageA');
     $this->themePackageInfo->expects($this->at(1))->method('getPackageName')->willReturn('packageB');
     $this->themePackageInfo->expects($this->at(2))->method('getPackageName')->willReturn('packageC');
     $this->remove->expects($this->once())->method('remove')->with(['packageA', 'packageB', 'packageC'])->willReturn('');
     $this->themeProvider->expects($this->never())->method($this->anything());
     $this->themeUninstaller->uninstallCode($this->output, ['frontend/Magento/ThemeA', 'frontend/Magento/ThemeB', 'frontend/Magento/ThemeC']);
 }
 /**
  * Run 'composer remove' to remove code
  *
  * @param OutputInterface $output
  * @param array $modules
  * @return void
  */
 public function uninstallCode(OutputInterface $output, array $modules)
 {
     $output->writeln('<info>Removing code from Magento codebase:</info>');
     $packages = [];
     /** @var \Magento\Framework\Module\PackageInfo $packageInfo */
     $packageInfo = $this->objectManager->get('Magento\\Framework\\Module\\PackageInfoFactory')->create();
     foreach ($modules as $module) {
         $packages[] = $packageInfo->getPackageName($module);
     }
     $this->remove->remove($packages);
 }
示例#5
0
 public function testRemove()
 {
     $composerApp = $this->getMock('Composer\\Console\\Application', ['setAutoExit', 'resetComposer', 'run'], [], '', false);
     $directoryList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false);
     $directoryList->expects($this->once())->method('getRoot');
     $directoryList->expects($this->once())->method('getPath')->with(DirectoryList::CONFIG)->willReturn(BP . '/app/etc');
     $composerApp->expects($this->once())->method('setAutoExit')->with(false);
     $composerApp->expects($this->once())->method('run');
     $remove = new Remove($composerApp, $directoryList);
     $remove->remove(['magento/package-a', 'magento/package-b']);
 }
 public function testUninstallRemoveCode()
 {
     $this->moduleRegistryUninstaller->expects($this->never())->method($this->anything());
     $this->output->expects($this->once())->method('writeln');
     $packageInfoFactory = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false);
     $packageInfo = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $packageInfo->expects($this->atLeastOnce())->method('getPackageName');
     $packageInfoFactory->expects($this->once())->method('create')->willReturn($packageInfo);
     $this->objectManager->expects($this->once())->method('get')->with('Magento\\Framework\\Module\\PackageInfoFactory')->willReturn($packageInfoFactory);
     $this->remove->expects($this->once())->method('remove');
     $this->uninstaller->uninstallCode($this->output, ['moduleA', 'moduleB']);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $languages = $input->getArgument(self::PACKAGE_ARGUMENT);
     $packagesToRemove = [];
     $dependencies = $this->dependencyChecker->checkDependencies($languages, true);
     foreach ($languages as $package) {
         if (!$this->validate($package)) {
             $output->writeln("<info>Package {$package} is not a Magento language and will be skipped.</info>");
         } else {
             if (sizeof($dependencies[$package]) > 0) {
                 $output->writeln("<info>Package {$package} has dependencies and will be skipped.</info>");
             } else {
                 $packagesToRemove[] = $package;
             }
         }
     }
     if ($packagesToRemove !== []) {
         if ($input->getOption(self::BACKUP_CODE_OPTION)) {
             $backupRestore = $this->backupRollbackFactory->create($output);
             $backupRestore->codeBackup(time());
         } else {
             $output->writeln('<info>You are removing language package without a code backup.</info>');
         }
         $output->writeln($this->remove->remove($packagesToRemove));
         $this->cache->clean();
     } else {
         $output->writeln('<info>Nothing is removed.</info>');
     }
 }
 public function setUpExecute()
 {
     $this->setUpPassValidation();
     $this->setupPassChildThemeCheck();
     $this->dependencyChecker->expects($this->once())->method('checkDependencies')->willReturn([]);
     $this->remove->expects($this->once())->method('remove');
     $this->cache->expects($this->once())->method('clean');
     $theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $this->themeProvider->expects($this->any())->method('getThemeByFullPath')->willReturn($theme);
 }
 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
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $themePaths = $input->getArgument(self::INPUT_KEY_THEMES);
     $validationMessages = $this->validate($themePaths);
     if (!empty($validationMessages)) {
         $output->writeln($validationMessages);
         return;
     }
     $isThemeInUseMessages = $this->themeValidator->validateIsThemeInUse($themePaths);
     if (!empty($isThemeInUseMessages)) {
         $output->writeln($isThemeInUseMessages);
         return;
     }
     $childThemeCheckMessages = $this->checkChildTheme($themePaths);
     if (!empty($childThemeCheckMessages)) {
         $output->writeln($childThemeCheckMessages);
         return;
     }
     $dependencyMessages = $this->checkDependencies($themePaths);
     if (!empty($dependencyMessages)) {
         $output->writeln($dependencyMessages);
         return;
     }
     try {
         $output->writeln('<info>Enabling maintenance mode</info>');
         $this->maintenanceMode->set(true);
         if ($input->getOption(self::INPUT_KEY_BACKUP_CODE)) {
             $time = time();
             $codeBackup = $this->backupRollbackFactory->create($output);
             $codeBackup->codeBackup($time);
         }
         $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from database');
         $this->removeFromDb($themePaths);
         $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from Magento codebase');
         $themePackages = [];
         foreach ($themePaths as $themePath) {
             $themePackages[] = $this->getPackageName($themePath);
         }
         $this->remove->remove($themePackages);
         $this->cleanup($input, $output);
         $output->writeln('<info>Disabling maintenance mode</info>');
         $this->maintenanceMode->set(false);
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         $output->writeln('<error>Please disable maintenance mode after you resolved above issues</error>');
     }
 }
示例#11
0
    /**
     * Run 'composer remove' to remove code
     *
     * @param array $modules
     * @return void
     */
    private function removeCode(array $modules)
    {
        $packages = [];
        foreach ($modules as $module) {
            $packages[] = $this->packageInfo->getPackageName($module);
        }
        $this->remove->remove($packages);

    }
    private function setUpExecute($input)
    {
        $this->setUpPassValidation();
        $this->remove->expects($this->once())->method('remove')->with(['magento/package-a', 'magento/package-b']);
        $this->dependencyChecker->expects($this->once())
            ->method('checkDependenciesWhenDisableModules')
            ->willReturn(['Magento_A' => [], 'Magento_B' => []]);
        $this->dataSetup->expects($this->exactly(count($input['module'])))->method('deleteTableRow');
        $this->deploymentConfig->expects($this->once())
            ->method('getConfigData')
            ->with(ConfigOptionsListConstants::KEY_MODULES)
            ->willReturn(['Magento_A' => 1, 'Magento_B' => 1, 'Magento_C' => 0, 'Magento_D' => 1]);

        $this->loader->expects($this->once())
            ->method('load')
            ->with($input['module'])
            ->willReturn(['Magento_C' => [], 'Magento_D' => []]);
        $this->writer->expects($this->once())
            ->method('saveConfig')
            ->with(
                [
                    ConfigFilePool::APP_CONFIG =>
                        [ConfigOptionsListConstants::KEY_MODULES => ['Magento_C' => 0, 'Magento_D' => 1]]
                ]
            );
        $this->cache->expects($this->once())->method('clean');
        $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses');

    }