/**
  * 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 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']);
 }
 public function testInteraction()
 {
     $input = ['module' => ['Magento_A', 'Magento_B']];
     $this->setUpExecute();
     $this->moduleUninstaller->expects($this->once())->method('uninstallCode')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDb')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDeploymentConfig')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->question->expects($this->once())->method('ask')->will($this->returnValue(false));
     $this->helperSet->expects($this->once())->method('get')->with('question')->will($this->returnValue($this->question));
     $this->command->setHelperSet($this->helperSet);
     $this->tester = new CommandTester($this->command);
     $this->tester->execute($input);
 }
 /**
  * Invoke remove data routine in each specified module
  *
  * @param string[] $modules
  * @param OutputInterface $output
  * @param bool $dbBackupOption
  * @return void
  */
 private function removeData(array $modules, OutputInterface $output, $dbBackupOption)
 {
     if (!$dbBackupOption) {
         $output->writeln('<error>You are removing data without a database backup.</error>');
     } else {
         $output->writeln('<info>Removing data</info>');
     }
     $this->moduleUninstaller->uninstallData($output, $modules);
 }