You are here

public function CommandTester::execute in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Tester/CommandTester.php \Symfony\Component\Console\Tester\CommandTester::execute()

Executes the command.

Available execution options:

  • interactive: Sets the input interactive flag
  • decorated: Sets the output decorated flag
  • verbosity: Sets the output verbosity flag

Parameters

array $input An array of command arguments and options:

array $options An array of execution options:

Return value

int The command exit code

File

vendor/symfony/console/Tester/CommandTester.php, line 56

Class

CommandTester
Eases the testing of console commands.

Namespace

Symfony\Component\Console\Tester

Code

public function execute(array $input, array $options = array()) {

  // set the command name automatically if the application requires
  // this argument and no command name was passed
  if (!isset($input['command']) && null !== ($application = $this->command
    ->getApplication()) && $application
    ->getDefinition()
    ->hasArgument('command')) {
    $input = array_merge(array(
      'command' => $this->command
        ->getName(),
    ), $input);
  }
  $this->input = new ArrayInput($input);
  if (isset($options['interactive'])) {
    $this->input
      ->setInteractive($options['interactive']);
  }
  $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  if (isset($options['decorated'])) {
    $this->output
      ->setDecorated($options['decorated']);
  }
  if (isset($options['verbosity'])) {
    $this->output
      ->setVerbosity($options['verbosity']);
  }
  return $this->statusCode = $this->command
    ->run($this->input, $this->output);
}