ApplicationTester
in package
Uses
TesterTrait
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);
Tags
Table of Contents
- $application : mixed
- $captureStreamsIndependently : mixed
- $input : InputInterface
- $inputs : mixed
- $output : StreamOutput
- $statusCode : int
- __construct() : mixed
- assertCommandIsSuccessful() : void
- getDisplay() : string
- Gets the display returned by the last execution of the command or application.
- getErrorOutput() : string
- Gets the output written to STDERR by the application.
- getInput() : InputInterface
- Gets the input instance used by the last execution of the command or application.
- getOutput() : OutputInterface
- Gets the output instance used by the last execution of the command or application.
- getStatusCode() : int
- Gets the status code returned by the last execution of the command or application.
- run() : int
- Executes the application.
- setInputs() : $this
- Sets the user inputs.
- createStream() : resource
- initOutput() : mixed
- Initializes the output property.
Properties
$application
private
mixed
$application
$captureStreamsIndependently
private
mixed
$captureStreamsIndependently
= false
$input
private
InputInterface
$input
$inputs
private
mixed
$inputs
= []
$output
private
StreamOutput
$output
$statusCode
private
int
$statusCode
Methods
__construct()
public
__construct(Application $application) : mixed
Parameters
- $application : Application
Return values
mixed —assertCommandIsSuccessful()
public
assertCommandIsSuccessful([string $message = '' ]) : void
Parameters
- $message : string = ''
Return values
void —getDisplay()
Gets the display returned by the last execution of the command or application.
public
getDisplay([bool $normalize = false ]) : string
Parameters
- $normalize : bool = false
Tags
Return values
string —getErrorOutput()
Gets the output written to STDERR by the application.
public
getErrorOutput([bool $normalize = false ]) : string
Parameters
- $normalize : bool = false
-
Whether to normalize end of lines to \n or not
Return values
string —getInput()
Gets the input instance used by the last execution of the command or application.
public
getInput() : InputInterface
Return values
InputInterface —getOutput()
Gets the output instance used by the last execution of the command or application.
public
getOutput() : OutputInterface
Return values
OutputInterface —getStatusCode()
Gets the status code returned by the last execution of the command or application.
public
getStatusCode() : int
Tags
Return values
int —run()
Executes the application.
public
run(array<string|int, mixed> $input[, array<string|int, mixed> $options = [] ]) : int
Available 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
- $input : array<string|int, mixed>
- $options : array<string|int, mixed> = []
Return values
int —The command exit code
setInputs()
Sets the user inputs.
public
setInputs(array<string|int, mixed> $inputs) : $this
Parameters
- $inputs : array<string|int, mixed>
-
An array of strings representing each input passed to the command input stream
Return values
$this —createStream()
private
static createStream(array<string|int, mixed> $inputs) : resource
Parameters
- $inputs : array<string|int, mixed>
Return values
resource —initOutput()
Initializes the output property.
private
initOutput(array<string|int, mixed> $options) : mixed
Available options:
- decorated: Sets the output decorated flag
- verbosity: Sets the output verbosity flag
- capture_stderr_separately: Make output of stdOut and stdErr separately available
Parameters
- $options : array<string|int, mixed>