コード例 #1
0
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Invalid format for --custom-fact 'foobar'
  */
 public function testGetCustomFactsInvalid()
 {
     $mock = $this->getMockForAbstractClass('SugarCli\\Console\\Command\\Inventory\\AbstractInventoryCommand', array('test'));
     $input = new ArrayInput(array('--custom-fact' => array('foobar')));
     $input->bind($mock->getDefinition());
     $mock->getCustomFacts($input, '');
 }
コード例 #2
0
 public function testBuildCommands()
 {
     $definition = new CommandDefinition('self-update');
     $definition->setDescription('Update spress.phar to the latest version.');
     $definition->setHelp('The self-update command replace your spress.phar by the latest version.');
     $definition->addOption('all');
     $definition->addArgument('dir');
     $input = new ArrayInput([]);
     $input->setInteractive(false);
     $output = new StreamOutput(fopen('php://memory', 'w', false));
     $commandPluginMock = $this->getMockBuilder('\\Yosymfony\\Spress\\Plugin\\CommandPlugin')->getMock();
     $commandPluginMock->expects($this->once())->method('getCommandDefinition')->will($this->returnValue($definition));
     $commandPluginMock->expects($this->once())->method('executeCommand');
     $pm = new PluginManager(new EventDispatcher());
     $pm->getPluginCollection()->add('emptyCommandPlugin', $commandPluginMock);
     $builder = new ConsoleCommandBuilder($pm);
     $symfonyConsoleCommands = $builder->buildCommands();
     $this->assertTrue(is_array($symfonyConsoleCommands));
     $this->assertCount(1, $symfonyConsoleCommands);
     $this->assertContainsOnlyInstancesOf('Symfony\\Component\\Console\\Command\\Command', $symfonyConsoleCommands);
     $symfonyConsoleCommand = $symfonyConsoleCommands[0];
     $this->assertCount(1, $symfonyConsoleCommand->getDefinition()->getOptions());
     $this->assertCount(1, $symfonyConsoleCommand->getDefinition()->getArguments());
     $this->assertEquals('Update spress.phar to the latest version.', $symfonyConsoleCommand->getDescription());
     $this->assertEquals('The self-update command replace your spress.phar by the latest version.', $symfonyConsoleCommand->getHelp());
     $symfonyConsoleCommand->run($input, $output);
 }
コード例 #3
0
 /**
  * @param ConsoleTerminateEvent $event
  */
 public function callCommands(ConsoleTerminateEvent $event)
 {
     /**
      * @var \Drupal\Console\Command\Command $command
      */
     $command = $event->getCommand();
     $output = $event->getOutput();
     if (!$command instanceof Command) {
         return;
     }
     $application = $command->getApplication();
     $commands = $application->getChain()->getCommands();
     if (!$commands) {
         return;
     }
     foreach ($commands as $chainedCommand) {
         if ($chainedCommand['name'] == 'module:install') {
             $messageHelper = $application->getMessageHelper();
             $translatorHelper = $application->getTranslator();
             $messageHelper->addErrorMessage($translatorHelper->trans('commands.chain.messages.module_install'));
             continue;
         }
         $callCommand = $application->find($chainedCommand['name']);
         $input = new ArrayInput($chainedCommand['inputs']);
         if (!is_null($chainedCommand['interactive'])) {
             $input->setInteractive($chainedCommand['interactive']);
         }
         $callCommand->run($input, $output);
     }
 }
コード例 #4
0
ファイル: DumpAutoloadTask.php プロジェクト: tenside/core
 /**
  * Prepare the input interface for the command.
  *
  * @return InputInterface
  */
 protected function prepareInput()
 {
     $arguments = ['--optimize' => (bool) $this->file->get(self::SETTING_OPTIMIZE), '--no-dev' => true];
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $input;
 }
コード例 #5
0
ファイル: CompareKeys.php プロジェクト: kreynen/elmsln
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $command = $this->getApplication()->find('translations:fetch');
     $arguments = array('command' => 'translations:fetch', '--username' => $input->getOption('username'), '--password' => $input->getOption('password'), '--keep-english' => true);
     $inputObject = new ArrayInput($arguments);
     $inputObject->setInteractive($input->isInteractive());
     $command->run($inputObject, $output);
     $englishFromOTrance = FetchFromOTrance::getDownloadPath() . DIRECTORY_SEPARATOR . 'en.json';
     if (!file_exists($englishFromOTrance)) {
         $output->writeln("English file from oTrance missing. Aborting");
         return;
     }
     $englishFromOTrance = json_decode(file_get_contents($englishFromOTrance), true);
     Translate::reloadLanguage('en');
     $availableTranslations = $GLOBALS['Piwik_translations'];
     $categories = array_unique(array_merge(array_keys($englishFromOTrance), array_keys($availableTranslations)));
     sort($categories);
     $unnecessary = $outdated = $missing = array();
     foreach ($categories as $category) {
         if (!empty($englishFromOTrance[$category])) {
             foreach ($englishFromOTrance[$category] as $key => $value) {
                 if (!array_key_exists($category, $availableTranslations) || !array_key_exists($key, $availableTranslations[$category])) {
                     $unnecessary[] = sprintf('%s_%s', $category, $key);
                     continue;
                 } else {
                     if (html_entity_decode($availableTranslations[$category][$key]) != html_entity_decode($englishFromOTrance[$category][$key])) {
                         $outdated[] = sprintf('%s_%s', $category, $key);
                         continue;
                     }
                 }
             }
         }
         if (!empty($availableTranslations[$category])) {
             foreach ($availableTranslations[$category] as $key => $value) {
                 if (!array_key_exists($category, $englishFromOTrance) || !array_key_exists($key, $englishFromOTrance[$category])) {
                     $missing[] = sprintf('%s_%s', $category, $key);
                     continue;
                 }
             }
         }
     }
     $output->writeln("");
     if (!empty($missing)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are missing on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $missing));
         $output->writeln("");
     }
     if (!empty($unnecessary)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys might be unnecessary on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $unnecessary));
         $output->writeln("");
     }
     if (!empty($outdated)) {
         $output->writeln("<bg=yellow;options=bold>-- Following keys are outdated on oTrance --</bg=yellow;options=bold>");
         $output->writeln(implode("\n", $outdated));
         $output->writeln("");
     }
     $output->writeln("Finished.");
 }
コード例 #6
0
ファイル: HelpCommand.php プロジェクト: mistymagich/gush
 private function updateCommandDefinition(Command $command, OutputInterface $output)
 {
     $eventDispatcher = $this->getApplication()->getDispatcher();
     $input = new ArrayInput(['command' => $command->getName()]);
     $event = new ConsoleCommandEvent($command, $input, $output);
     $eventDispatcher->dispatch(GushEvents::DECORATE_DEFINITION, $event);
     $command->getSynopsis(true);
     $command->getSynopsis(false);
     $command->mergeApplicationDefinition();
     try {
         $input->bind($command->getDefinition());
     } catch (\Exception $e) {
         $output->writeln('<error>Something went wrong: </error>' . $e->getMessage());
         return;
     }
     $eventDispatcher->dispatch(GushEvents::INITIALIZE, $event);
     // The options were set on the input but now we need to set them on the Command definition
     if ($options = $input->getOptions()) {
         foreach ($options as $name => $value) {
             $option = $command->getDefinition()->getOption($name);
             if ($option->acceptValue()) {
                 $option->setDefault($value);
             }
         }
     }
 }
コード例 #7
0
ファイル: InstallCommand.php プロジェクト: symedit/symedit
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $force = (bool) $input->getOption('force');
     $dialog = $this->getHelperSet()->get('dialog');
     // Doctrine create database
     if ($force || $dialog->askConfirmation($output, '<question>Create Database?</question>', false)) {
         $output->writeln('Creating database...');
         $command = $this->getApplication()->find('doctrine:database:create');
         $input = new ArrayInput(['command' => 'doctrine:database:create', '-n' => $force]);
         $returnCode = $command->run($input, $output);
     }
     // Doctrine schema update
     if ($force || $dialog->askConfirmation($output, '<question>Load Schema?</question>', false)) {
         $output->writeln('Loading Schema...');
         $command = $this->getApplication()->find('doctrine:schema:update');
         $input = new ArrayInput(['command' => 'doctrine:schema:update', '--force' => true, '-n' => $force]);
         $returnCode = $command->run($input, $output);
     }
     // Doctrine Fixtures
     if ($force || $dialog->askConfirmation($output, '<question>Load Fixtures?</question>', false)) {
         $output->writeln('Loading Fixtures...');
         $command = $this->getApplication()->find('doctrine:fixtures:load');
         $input = new ArrayInput(['doctrine:fixtures:load']);
         $input->setInteractive(!$force);
         $returnCode = $command->run($input, $output);
     }
     $output->writeln('Finished.');
 }
コード例 #8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->isEnabled()) {
         $bundleName = $input->getArgument("bundle");
         $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
         /* @var $bundle BundleInterface */
         $entities = array();
         foreach ($this->getBundleMetadata($bundle) as $m) {
             /* @var $m ClassMetadata */
             $_tmp = explode('\\', $m->getName());
             $entityName = array_pop($_tmp);
             $entities[$bundleName . ':' . $entityName] = $entityName;
         }
         $command = $this->getApplication()->find('itscaro:generate:crud');
         foreach ($entities as $entityShortcut => $entityName) {
             try {
                 $_input = new ArrayInput(['command' => 'itscaro:generate:crud', '--entity' => $entityShortcut, '--route-prefix' => $input->getOption('route-prefix') . strtolower($entityName), '--with-write' => $input->getOption('with-write'), '--format' => $input->getOption('format'), '--overwrite' => $input->getOption('overwrite')]);
                 $_input->setInteractive($input->isInteractive());
                 $output->writeln("<info>Executing:</info> {$_input}");
                 $returnCode = $command->run($_input, $output);
                 $output->writeln("\t<info>Done</info>");
             } catch (\Exception $e) {
                 $output->writeln("\t<error>Error:</error> " . $e->getMessage());
             }
         }
     } else {
         $output->writeln('<error>Cannot find DoctrineBundle</error>');
     }
 }
コード例 #9
0
 public function testShouldNotClearScreenInNotInteractiveMode()
 {
     $SUT = $this->createSUT();
     $this->input->setInteractive(false);
     $SUT->cls();
     $this->assertEquals('', $this->output->fetch());
 }
コード例 #10
0
 /**
  * Run doctrine migrations
  */
 protected function handleMigrations()
 {
     $application = $this->getApplication();
     $commandInput = new ArrayInput(array('command' => 'doctrine:migrations:migrate'));
     $commandInput->setInteractive(false);
     $application->doRun($commandInput, $this->output);
 }
コード例 #11
0
 /**
  * Initialize the command and determine which path to take
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @internal param $ Symfony\Component\Console\Input\InputInterface
  * @internal param $ Symfony\Component\Console\Output\OutputInterface
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     switch ($this->input->getArgument('key')) {
         case 'folder':
             $this->newFolder();
             break;
         case 'site':
             $this->newSite();
             break;
         case 'database':
             $this->newDatabase();
             break;
         case 'variable':
             $this->newVariable();
             break;
         case 'list':
             $this->listKeys();
             break;
         default:
             $helpCommand = $this->getApplication()->find('config:new');
             $input = new ArrayInput(['key' => 'list', '--file' => $input->getOption('file')]);
             $helpCommand->run($input, $output);
             break;
     }
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = 'build/portable-zip-api.zip';
     $pharCommand = $this->getApplication()->find('build:phar');
     $arrayInput = new ArrayInput(array('command' => 'build:phar'));
     $arrayInput->setInteractive(false);
     if ($pharCommand->run($arrayInput, $output)) {
         $output->writeln('The operation is aborted due to build:phar command');
         return 1;
     }
     if (file_exists($file)) {
         $output->writeln('Removing previous package');
         unlink($file);
     }
     $zip = new \ZipArchive();
     if ($zip->open($file, \ZipArchive::CREATE) !== true) {
         $output->writeln('Failed to open zip archive');
         return 1;
     }
     $zip->addFile('build/zip.phar.php', 'zip.phar.php');
     $zip->addFile('app/zip.sqlite.db', 'zip.sqlite.db');
     $zip->addFile('README.md', 'README.md');
     $zip->close();
     return 0;
 }
コード例 #13
0
 public function testGetConfig()
 {
     file_put_contents('box.json', '{}');
     $command = $this->app->get('test');
     $input = new ArrayInput(array());
     $input->bind($command->getDefinition());
     $this->assertInstanceOf('KevinGH\\Box\\Configuration', $this->callMethod($command, 'getConfig', array($input)));
 }
コード例 #14
0
 private function executeCommand($command, $arguments, OutputInterface $output)
 {
     $command = $this->getApplication()->find($command);
     $arguments['command'] = $command;
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $command->run($input, $output);
 }
コード例 #15
0
 /**
  * @param null|string|array $config
  */
 private function launchCommand($config = null)
 {
     $app = new Application(self::$kernel->getContainer()->get('kernel'));
     $app->setAutoExit(false);
     $input = new ArrayInput(array('command' => 'modera:languages:config-sync-dummy', 'config' => $config ? json_encode($config) : null));
     $input->setInteractive(false);
     $result = $app->run($input, new NullOutput());
     $this->assertEquals(0, $result);
 }
コード例 #16
0
ファイル: testBootstrap.php プロジェクト: vegardbb/webpage
function executeCommand($application, $command, array $options = array())
{
    $options["--env"] = "test";
    $options["--quiet"] = true;
    $options = array_merge($options, array('command' => $command));
    $arrayInput = new ArrayInput($options);
    $arrayInput->setInteractive(false);
    $application->run($arrayInput);
}
コード例 #17
0
 protected function launchImportCommand()
 {
     $app = new Application(self::$container->get('kernel'));
     $app->setAutoExit(false);
     $input = new ArrayInput(array('command' => 'modera:translations:import'));
     $input->setInteractive(false);
     $exitCode = $app->run($input, new NullOutput());
     $this->assertEquals(0, $exitCode);
 }
コード例 #18
0
ファイル: UpdateCommand.php プロジェクト: miguelibero/meinhof
 protected function runSetup(InputInterface $input, OutputInterface $output)
 {
     $command = new SetupCommand();
     if ($helper = $this->getHelperSet()) {
         $command->setHelperSet($helper);
     }
     $input = new ArrayInput(array('dir' => $input->getArgument('dir'), '--update' => false));
     $command->run($input, $output);
 }
コード例 #19
0
 public function update($name)
 {
     $app = new Application();
     $app->setAutoExit(false);
     $input = new ArrayInput(['update', 'packages' => [$name]]);
     $input->setInteractive(false);
     $output = new BufferedOutput();
     $app->run($input, $output);
     return $output->fetch();
 }
コード例 #20
0
ファイル: UpgradeTask.php プロジェクト: aschempp/tenside-core
 /**
  * {@inheritDoc}
  */
 protected function prepareInput()
 {
     $arguments = [];
     if ($this->isSelectiveUpgrade()) {
         $arguments['packages'] = $this->getPackages();
     }
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $input;
 }
コード例 #21
0
 /**
  * {@inheritDoc}
  */
 protected function prepareInput()
 {
     $arguments = ['packages' => $this->getPackage()];
     if ($this->isNoUpdate()) {
         $arguments['no-update'] = '';
     }
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $input;
 }
コード例 #22
0
 protected function executeCommand(OutputInterface $output, $arguments)
 {
     $app = $this->getApplication();
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     $returnCode = $app->doRun($input, $output);
     if ($returnCode == 0) {
         return true;
     }
     return false;
 }
コード例 #23
0
 public function runCommands()
 {
     foreach ($this->commands as &$command) {
         if ($command['once'] && $command['runCount'] > 0) {
             continue;
         }
         $input = new ArrayInput($command['options']);
         $input->setInteractive(false);
         $this->application->run($input, $this->output);
         $command['runCount']++;
     }
 }
コード例 #24
0
ファイル: FixtureCommand.php プロジェクト: CampaignChain/core
 private function loadSchemaUpdateVersions(InputInterface $input, OutputInterface $output)
 {
     $app = $this->getApplication();
     $input = new ArrayInput(array('command' => 'doctrine:migrations:version', '--add' => true, '--all' => true));
     $input->setInteractive(false);
     $returnCode = $app->doRun($input, $output);
     if ($returnCode == 0) {
         return true;
     } else {
         return false;
     }
 }
コード例 #25
0
ファイル: commandtest.php プロジェクト: farukuzun/core-1
 protected function getInput(Command $command, array $arguments = [], array $options = [])
 {
     $input = new ArrayInput([]);
     $input->bind($command->getDefinition());
     foreach ($arguments as $key => $value) {
         $input->setArgument($key, $value);
     }
     foreach ($options as $key => $value) {
         $input->setOption($key, $value);
     }
     return $input;
 }
コード例 #26
0
 /**
  * @param $name
  * @param array $params
  * @return int Command exit code
  * @throws \Exception
  *
  */
 private static function runCommandStatic($name, array $params = array())
 {
     array_unshift($params, $name);
     $input = new ArrayInput($params);
     $input->setInteractive(false);
     $fp = fopen('php://temp/maxmemory', 'r+');
     $output = new StreamOutput($fp);
     self::getApplication()->run($input, $output);
     rewind($fp);
     $returnOutput = stream_get_contents($fp);
     return $returnOutput;
 }
コード例 #27
0
ファイル: WebTestCase.php プロジェクト: KnpLabs/KnpUserBundle
 protected function runCommand($name, array $params = array())
 {
     \array_unshift($params, $name);
     $kernel = $this->createKernel();
     $kernel->boot();
     $application = new Application($kernel);
     $application->setAutoExit(false);
     $input = new ArrayInput($params);
     $input->setInteractive(false);
     $ouput = new NullOutput(0);
     $application->run($input, $ouput);
 }
コード例 #28
0
ファイル: CompositeCommand.php プロジェクト: nike/beez
 protected function addCommandArray(array $args, OutputInterface $output)
 {
     $command = $this->getApplication()->find($args['command']);
     if ($command instanceof CompositeCommand) {
         unset($args['command']);
         $input = new ArrayInput($args);
         $input->bind($command->getDefinition());
         $command->initialize($input, $output);
     } else {
         $input = new ArrayInput($args);
         self::$commands[] = array('command' => $command, 'input' => $input);
     }
 }
コード例 #29
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $consumers = ['google_create', 'google_update', 'google_delete'];
     if (null !== ($consumer = $input->getArgument('consumer'))) {
         $consumers = [$consumer];
     }
     foreach ($consumers as $consumer) {
         $output->writeln(sprintf('Request to purge sent to %s', $consumer));
         $inputCommand = new ArrayInput(['command' => 'rabbitmq:purge', 'name' => $consumer]);
         $inputCommand->setInteractive(false);
         $this->getApplication()->doRun($inputCommand, $output);
         $output->writeln(sprintf('<info>Consumer %s purged</info>', $consumer));
     }
 }
コード例 #30
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = $this->getApplication()->getConfig();
     foreach ($config['models'] as $className => $model) {
         if (is_array($model)) {
             $arrayInputArgs = ['modelName' => $model["modelName"]];
         } else {
             $arrayInputArgs = ['modelName' => $model];
         }
         $command = $this->getApplication()->find('generate:config');
         $arrayInput = new ArrayInput($arrayInputArgs, $command->getNativeDefinition());
         $arrayInput->setInteractive(true);
         $command->execute($arrayInput, $output);
     }
 }