CommandTester
in package
uses
TesterTrait
Eases the testing of console commands.
Tags
Table of Contents
Properties
- $captureStreamsIndependently : mixed
- $command : mixed
- $input : mixed
- $inputs : mixed
- $output : StreamOutput
- $statusCode : mixed
Methods
- __construct() : mixed
- execute() : int
- Executes the command.
- 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.
- setInputs() : $this
- Sets the user inputs.
- createStream() : resource
- initOutput() : mixed
- Initializes the output property.
Properties
$captureStreamsIndependently
private
mixed
$captureStreamsIndependently
= false
$command
private
mixed
$command
$input
private
mixed
$input
$inputs
private
mixed
$inputs
= []
$output
private
StreamOutput
$output
$statusCode
private
mixed
$statusCode
Methods
__construct()
public
__construct(Command $command) : mixed
Parameters
- $command : Command
execute()
Executes the command.
public
execute(array<string|int, mixed> $input[, array<string|int, mixed> $options = [] ]) : int
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
- $input : array<string|int, mixed>
-
An array of command arguments and options
- $options : array<string|int, mixed> = []
-
An array of execution options
Return values
int —The command exit code
getDisplay()
Gets the display returned by the last execution of the command or application.
public
getDisplay([bool $normalize = false ]) : string
Parameters
- $normalize : bool = false
-
Whether to normalize end of lines to \n or not
Return values
string —The display
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
stringgetInput()
Gets the input instance used by the last execution of the command or application.
public
getInput() : InputInterface
Return values
InputInterface —The current input instance
getOutput()
Gets the output instance used by the last execution of the command or application.
public
getOutput() : OutputInterface
Return values
OutputInterface —The current output instance
getStatusCode()
Gets the status code returned by the last execution of the command or application.
public
getStatusCode() : int
Return values
int —The status 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
$thiscreateStream()
private
static createStream(array<string|int, mixed> $inputs) : resource
Parameters
- $inputs : array<string|int, mixed>
Return values
resourceinitOutput()
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>