Example #1
0
 /**
  * Initialize, check arguments and options values etc.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $output->writeln(sprintf('<info>Steward</info> <comment>%s</comment> is running the tests...%s', $this->getApplication()->getVersion(), !$this->isCi() ? ' Just for you <fg=red><3</fg=red>!' : ''));
     // If browser name or env is empty, ends initialization and let the Console/Command fail on input validation
     if (empty($input->getArgument(self::ARGUMENT_BROWSER)) || empty($input->getArgument(self::ARGUMENT_ENVIRONMENT))) {
         return;
     }
     // Browser name is case insensitive, normalize it to lower case
     $input->setArgument(self::ARGUMENT_BROWSER, strtolower($input->getArgument(self::ARGUMENT_BROWSER)));
     $browser = $input->getArgument(self::ARGUMENT_BROWSER);
     // Check if browser is supported
     if (!in_array($browser, $this->supportedBrowsers)) {
         throw new \RuntimeException(sprintf('Browser "%s" is not supported (use one of: %s)', $browser, implode(', ', $this->supportedBrowsers)));
     }
     $output->writeln(sprintf('Browser: %s', $browser));
     $output->writeln(sprintf('Environment: %s', $input->getArgument(self::ARGUMENT_ENVIRONMENT)));
     // Check if directories exists
     $this->testDirectories($input, $output, [$this->getDefinition()->getOption(self::OPTION_TESTS_DIR), $this->getDefinition()->getOption(self::OPTION_LOGS_DIR), $this->getDefinition()->getOption(self::OPTION_FIXTURES_DIR)]);
     if ($output->isDebug()) {
         $output->writeln(sprintf('Base path to fixtures results: %s', $input->getOption(self::OPTION_FIXTURES_DIR)));
         $output->writeln(sprintf('Path to logs: %s', $input->getOption(self::OPTION_LOGS_DIR)));
         $output->writeln(sprintf('Publish results: %s', $input->getOption(self::OPTION_PUBLISH_RESULTS) ? 'yes' : 'no'));
     }
 }
Example #2
0
 /**
  * Prepare ExtendedConsoleEvent that could be passed to onCommandRunTestsInit().
  *
  * @param Command $command
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return ExtendedConsoleEvent
  */
 protected function prepareExtendedConsoleEvent($command, $input, $output)
 {
     // Trigger event to add the xdebug option to the command and bind the definition to the input
     $this->listener->onCommandConfigure(new BasicConsoleEvent($command));
     $input->bind($command->getDefinition());
     $event = new ExtendedConsoleEvent($command, $input, $output);
     return $event;
 }