class CommandTester

Eases the testing of console commands.

Methods

__construct(Command $command)

Constructor.

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

Executes the command.

string
getDisplay(bool $normalize = false)

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

getInput()

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

getOutput()

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

int
getStatusCode()

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

setInputs(array $inputs)

Sets the user inputs.

Details

at line line 39
__construct(Command $command)

Constructor.

Parameters

Command $command A Command instance to test

at line line 58
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

at line line 96
string getDisplay(bool $normalize = false)

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

Parameters

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

Return Value

string The display

at line line 114
InputInterface getInput()

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

Return Value

InputInterface The current input instance

at line line 124
OutputInterface getOutput()

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

Return Value

OutputInterface The current output instance

at line line 134
int getStatusCode()

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

Return Value

int The status code

at line line 147
CommandTester setInputs(array $inputs)

Sets the user inputs.

Parameters

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

Return Value

CommandTester