Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CommandTester.php

function 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
  • capture_stderr_separately: Make output of stdOut and stdErr separately available

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 47

Class

CommandTester
Eases the testing of console commands.

Namespace

Symfony\Component\Console\Tester

Code

public function execute(array $input, array $options = []) : int {
    // 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([
            'command' => $this->command
                ->getName(),
        ], $input);
    }
    $this->input = new ArrayInput($input);
    // Use an in-memory input stream even if no inputs are set so that QuestionHelper::ask() does not rely on the blocking STDIN.
    $this->input
        ->setStream(self::createStream($this->inputs));
    if (isset($options['interactive'])) {
        $this->input
            ->setInteractive($options['interactive']);
    }
    if (!isset($options['decorated'])) {
        $options['decorated'] = false;
    }
    $this->initOutput($options);
    return $this->statusCode = $this->command
        ->run($this->input, $this->output);
}
RSS feed
Powered by Drupal