/**
  * Removes module from setup_module table
  *
  * @param OutputInterface $output
  * @param string[] $modules
  * @return void
  */
 public function removeModulesFromDb(OutputInterface $output, array $modules)
 {
     $output->writeln('<info>Removing ' . implode(', ', $modules) . ' from module registry in database</info>');
     /** @var \Magento\Framework\Setup\ModuleDataSetupInterface $setup */
     $setup = $this->dataSetupFactory->create();
     foreach ($modules as $module) {
         $setup->deleteTableRow('setup_module', 'module', $module);
     }
 }
 /**
  * Collect Uninstall classes from modules
  *
  * @param array $filterModules
  * @return UninstallInterface[]
  */
 public function collectUninstall($filterModules = [])
 {
     $uninstallList = [];
     /** @var \Magento\Setup\Module\DataSetup $setup */
     $setup = $this->dataSetupFactory->create();
     $result = $setup->getConnection()->select()->from($setup->getTable('setup_module'), ['module']);
     if (isset($filterModules) && sizeof($filterModules) > 0) {
         $result->where('module in( ? )', implode(',', $filterModules));
     }
     // go through modules
     foreach ($setup->getConnection()->fetchAll($result) as $row) {
         $uninstallClassName = str_replace('_', '\\', $row['module']) . '\\Setup\\Uninstall';
         if (class_exists($uninstallClassName)) {
             $uninstallClass = $this->objectManager->create($uninstallClassName);
             if (is_subclass_of($uninstallClass, 'Magento\\Framework\\Setup\\UninstallInterface')) {
                 $uninstallList[$row['module']] = $uninstallClass;
             }
         }
     }
     return $uninstallList;
 }
 public function testCreate()
 {
     $resource = $this->getMock('Magento\\Framework\\App\\ResourceConnection', [], [], '', false);
     $filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $context = $this->getMock('Magento\\Framework\\Module\\Setup\\Context', [], [], '', false);
     $context->expects($this->once())->method('getEventManager');
     $context->expects($this->once())->method('getLogger');
     $context->expects($this->once())->method('getMigrationFactory');
     $context->expects($this->once())->method('getResourceModel')->willReturn($resource);
     $context->expects($this->once())->method('getFilesystem')->willReturn($filesystem);
     $objectManager = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface', [], '', false);
     $objectManager->expects($this->once())->method('get')->with('Magento\\Framework\\Module\\Setup\\Context')->willReturn($context);
     $objectManagerProvider = $this->getMock('Magento\\Setup\\Model\\ObjectManagerProvider', [], [], '', false);
     $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
     $factory = new DataSetupFactory($objectManagerProvider);
     $this->assertInstanceOf('Magento\\Setup\\Module\\DataSetup', $factory->create());
 }
 /**
  * Installs data fixtures
  *
  * @return void
  * @throws \Exception
  */
 public function installDataFixtures()
 {
     $setup = $this->dataSetupFactory->create();
     $this->checkInstallationFilePermissions();
     $this->log->log('Data install/update:');
     $this->handleDBSchemaData($setup, 'data');
 }