Exemplo n.º 1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->dialog = $this->getApplication()->getDialogHelper();
     $this->filesystem = new Filesystem();
     if ($input->isInteractive()) {
         return;
     }
     // if the qa-tools.json of a full previous run are loaded, we support the --no-interaction (-n) flag.
     // This is achieved by making the dialog input-aware, see \Symfony\Console\Helper\DialogHelper::ask()
     // lines 101-103 and \Symfony\Console\Helper\InputAwareHelper
     if (!$this->settings->hasLoadedJsonFile() || !$this->settings->previousRunWasCompleted()) {
         $output->writeln('<error>Previous run was not completed fully, cannot run in non-interactive mode</error>');
         // stop with error
         exit(1);
     }
     $this->dialog->setInput($input);
 }
 public function testNoInteraction()
 {
     $dialog = new DialogHelper();
     $input = new ArrayInput(array());
     $input->setInteractive(false);
     $dialog->setInput($input);
     $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet'));
 }