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();
     }
 }
Example #2
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @throws \RuntimeException
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectContao($output);
     if ($this->initContao()) {
         $fileName = $input->getArgument('log_filename');
         if ($fileName === null) {
             $path = $this->askLogFile($output);
         } else {
             $path = $this->getLogDir() . DIRECTORY_SEPARATOR . $fileName;
         }
         if ($this->logfileExists(basename($path))) {
             $size = @filesize($path);
             if ($size === false) {
                 throw new \RuntimeException('Couldn\\t detect filesize.');
             }
         } else {
             $size = 0;
         }
         if ($input->getOption('human')) {
             $output->writeln(\IMI\Util\Filesystem::humandFilesize($size));
         } else {
             $output->writeln("{$size}");
         }
     }
 }
 /**
  * @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');
         }
     }
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return bool
  */
 public function downloadContao(InputInterface $input, OutputInterface $output)
 {
     try {
         $package = $this->createComposerPackageByConfig($this->config['contaoVersionData']);
         $this->config['contaoPackage'] = $package;
         if (file_exists($this->config['installationFolder'] . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Mage.php')) {
             $output->writeln('<error>A contao installation already exists in this folder </error>');
             return false;
         }
         $composer = $this->getComposer($input, $output);
         $targetFolder = $this->getTargetFolderByType($composer, $package, $this->config['installationFolder']);
         $this->config['contaoPackage'] = $this->downloadByComposerConfig($input, $output, $package, $targetFolder, true);
         if ($this->isSourceTypeRepository($package->getSourceType())) {
             $filesystem = new \IMI\Util\Filesystem();
             $filesystem->recursiveCopy($targetFolder, $this->config['installationFolder'], array('.git', '.hg'));
         } else {
             $filesystem = new \Composer\Util\Filesystem();
             $filesystem->copyThenRemove($this->config['installationFolder'] . '/_imi_conrun_download', $this->config['installationFolder']);
         }
         if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
             // Patch installer
             $this->patchContaoInstallerForPHP54($this->config['installationFolder']);
         }
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
         return false;
     }
     return true;
 }
 /**
  * @param array $vars
  *
  * @return array
  */
 protected function formatVariables(array $vars)
 {
     $rounding = (int) $this->_input->getOption('rounding');
     if ($rounding > -1) {
         foreach ($vars as $k => &$v) {
             if (true === $this->allowRounding($k)) {
                 $v = Filesystem::humanFileSize($v, $rounding);
             }
             if (isset($this->_specialFormat[$k])) {
                 $v = $this->{$this->_specialFormat[$k]}($v);
             }
         }
         unset($v);
     }
     $maxWidth = $this->getMaxValueWidth($vars);
     // align=right
     foreach ($vars as &$v) {
         $v = str_pad($v, $maxWidth, ' ', STR_PAD_LEFT);
     }
     return $vars;
 }