/**
  * @dataProvider executeFailedChildThemeCheckDataProvider
  * @param bool $hasVirtual
  * @param bool $hasPhysical
  * @param array $input
  * @param string $expected
  * @return void
  */
 public function testExecuteFailedChildThemeCheck($hasVirtual, $hasPhysical, array $input, $expected)
 {
     $theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $theme->expects($this->any())->method('hasChildThemes')->willReturn($hasVirtual);
     $parentThemeA = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $parentThemeA->expects($this->any())->method('getFullPath')->willReturn('frontend/Magento/a');
     $parentThemeB = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $parentThemeB->expects($this->any())->method('getFullPath')->willReturn('frontend/Magento/b');
     $childThemeC = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $childThemeC->expects($this->any())->method('getFullPath')->willReturn('frontend/Magento/c');
     $childThemeD = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false);
     $childThemeD->expects($this->any())->method('getFullPath')->willReturn('frontend/Magento/d');
     if ($hasPhysical) {
         $childThemeC->expects($this->any())->method('getParentTheme')->willReturn($parentThemeA);
         $childThemeD->expects($this->any())->method('getParentTheme')->willReturn($parentThemeB);
     }
     $this->themeProvider->expects($this->any())->method('getThemeByFullPath')->willReturn($theme);
     $this->themeCollection->expects($this->any())->method('getIterator')->willReturn(new \ArrayIterator([$childThemeC, $childThemeD]));
     $this->assertEquals($expected, $this->themeDependencyChecker->checkChildTheme($input));
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $messages = [];
     $themePaths = $input->getArgument(self::INPUT_KEY_THEMES);
     $messages = array_merge($messages, $this->validate($themePaths));
     if (!empty($messages)) {
         $output->writeln($messages);
         return;
     }
     $messages = array_merge($messages, $this->themeValidator->validateIsThemeInUse($themePaths), $this->themeDependencyChecker->checkChildTheme($themePaths), $this->checkDependencies($themePaths));
     if (!empty($messages)) {
         $output->writeln('<error>Unable to uninstall. Please resolve the following issues:</error>' . PHP_EOL . implode(PHP_EOL, $messages));
         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);
         }
         $this->themeUninstaller->uninstallRegistry($output, $themePaths);
         $this->themeUninstaller->uninstallCode($output, $themePaths);
         $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>');
     }
 }