class ApplicationTester

Eases the testing of console applications.

When testing an application, don't forget to disable the auto exit flag:

$application = new Application();
$application->setAutoExit(false);

Traits

Methods

string
getDisplay(bool $normalize = false)

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

getInput()

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

getOutput()

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

int
getStatusCode()

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

setInputs(array $inputs)

Sets the user inputs.

__construct(Application $application)

No description

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

Executes the application.

string
getErrorOutput(bool $normalize = false)

Gets the output written to STDERR by the application.

Details

in TesterTrait at line line 36
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

in TesterTrait at line line 54
InputInterface getInput()

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

Return Value

InputInterface The current input instance

in TesterTrait at line line 64
OutputInterface getOutput()

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

Return Value

OutputInterface The current output instance

in TesterTrait at line line 74
int getStatusCode()

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

Return Value

int The status code

in TesterTrait at line line 87
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

at line line 38
__construct(Application $application)

Parameters

Application $application

at line line 58
int run(array $input, array $options = array())

Executes the application.

Available options:

  • interactive: Sets the input interactive flag
  • decorated: Sets the output decorated flag
  • verbosity: Sets the output verbosity flag
  • capturestderrseparately: Make output of stdOut and stdErr separately available

Parameters

array $input An array of arguments and options
array $options An array of options

Return Value

int The command exit code

at line line 117
string getErrorOutput(bool $normalize = false)

Gets the output written to STDERR by the application.

Parameters

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

Return Value

string