W3cubDocs

/Symfony 4.1

CommandTester

class CommandTester

Eases the testing of console commands.

Traits

TesterTrait

Methods

string getDisplay(bool $normalize = false)

Gets the display returned by the last execution of the command or application.

from TesterTrait
InputInterface getInput()

Gets the input instance used by the last execution of the command or application.

from TesterTrait
OutputInterface getOutput()

Gets the output instance used by the last execution of the command or application.

from TesterTrait
int getStatusCode()

Gets the status code returned by the last execution of the command or application.

from TesterTrait
TesterTrait setInputs(array $inputs)

Sets the user inputs.

from TesterTrait
__construct(Command $command)
int execute(array $input, array $options = array())

Executes the command.

Details

string getDisplay(bool $normalize = false)

Gets the display returned by the last execution of the command or application.

Parameters

bool $normalize Whether to normalize end of lines to \n or not

Return Value

string The display

InputInterface getInput()

Gets the input instance used by the last execution of the command or application.

Return Value

InputInterface The current input instance

OutputInterface getOutput()

Gets the output instance used by the last execution of the command or application.

Return Value

OutputInterface The current output instance

int getStatusCode()

Gets the status code returned by the last execution of the command or application.

Return Value

int The status code

TesterTrait setInputs(array $inputs)

Sets the user inputs.

Parameters

array $inputs array An array of strings representing each input passed to the command input stream

Return Value

TesterTrait

__construct(Command $command)

Parameters

Command $command

int execute(array $input, array $options = array())

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

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Tester/CommandTester.html