public function testExecute() { $application = $this->getApplication(); $application->add(new ListCommand()); $command = $this->getApplication()->find('dev:module:create'); $root = getcwd(); // delete old module if (is_dir($root . '/IMIContrun_UnitTest')) { $filesystem = new Filesystem(); $filesystem->recursiveRemoveDirectory($root . '/IMIContrun_UnitTest'); clearstatcache(); } $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--add-all' => true, '--add-setup' => true, '--add-readme' => true, '--add-composer' => true, '--modman' => true, '--description' => 'Unit Test Description', '--author-name' => 'Unit Test', '--author-email' => '*****@*****.**', 'vendorNamespace' => 'IMIContrun', 'moduleName' => 'UnitTest')); $this->assertFileExists($root . '/IMIContrun_UnitTest/composer.json'); $this->assertFileExists($root . '/IMIContrun_UnitTest/readme.md'); $moduleBaseFolder = $root . '/IMIContrun_UnitTest/src/app/code/local/IMIContrun/UnitTest/'; $this->assertFileExists($moduleBaseFolder . 'etc/config.xml'); $this->assertFileExists($moduleBaseFolder . 'Block'); $this->assertFileExists($moduleBaseFolder . 'Model'); $this->assertFileExists($moduleBaseFolder . 'Helper'); $this->assertFileExists($moduleBaseFolder . 'data/imiconrun_unittest_setup'); $this->assertFileExists($moduleBaseFolder . 'sql/imiconrun_unittest_setup'); // delete old module if (is_dir($root . '/IMIContrun_UnitTest')) { $filesystem = new Filesystem(); $filesystem->recursiveRemoveDirectory($root . '/IMIContrun_UnitTest'); clearstatcache(); } }
/** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int|void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->chooseInstallationFolder($input, $output); $this->detectContao($output); $this->getApplication()->setAutoExit(false); $dialog = $this->getHelperSet()->get('dialog'); /* @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ $shouldUninstall = $input->getOption('force'); if (!$shouldUninstall) { $shouldUninstall = $dialog->askConfirmation($output, '<question>Really uninstall ?</question> <comment>[n]</comment>: ', false); } if ($shouldUninstall) { $input = new StringInput('db:drop --force'); $this->getApplication()->run($input, $output); $fileSystem = new Filesystem(); $output->writeln('<info>Remove directory </info><comment>' . $this->_contaoRootFolder . '</comment>'); try { $fileSystem->recursiveRemoveDirectory($this->_contaoRootFolder); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); } $output->writeln('<info>Done</info>'); } }
/** * Remove empty composer extraction folder */ protected function removeEmptyFolders() { if (is_dir(getcwd() . '/vendor')) { $finder = new Finder(); $finder->files()->depth(3)->in(getcwd() . '/vendor'); if ($finder->count() == 0) { $filesystem = new Filesystem(); $filesystem->recursiveRemoveDirectory(getcwd() . '/vendor'); } } }