PendingCommand

class PendingCommand (View source)

Properties

TestCase $test The test being run.
protected Container $app The application instance.
protected string $command The command to run.
protected array $parameters The parameters to pass to the command.
protected int $expectedExitCode The expected exit code.
protected bool $hasExecuted Determine if command has executed.

Methods

void __construct(TestCase $test, Container $app, string $command, array $parameters)

Create a new pending console command run.

$this expectsQuestion(string $question, string|bool $answer)

Specify an expected question that will be asked when the command runs.

$this expectsConfirmation(string $question, string $answer = 'no')

Specify an expected confirmation question that will be asked when the command runs.

$this expectsChoice(string $question, string|array $answer, array $answers, bool $strict = false)

Specify an expected choice question with expected answers that will be asked/shown when the command runs.

$this expectsOutput(string $output)

Specify output that should be printed when the command runs.

$this expectsTable(array $headers, Arrayable|array $rows, string $tableStyle = 'default', array $columnStyles = [])

Specify a table that should be printed when the command runs.

$this assertExitCode(int $exitCode)

Assert that the command has the given exit code.

int execute()

Execute the command.

int run()

Execute the command.

void verifyExpectations()

Determine if expected questions / choices / outputs are fulfilled.

MockInterface mockConsoleOutput()

Mock the application's console output.

void __destruct()

Handle the object's destruction.

Details

void __construct(TestCase $test, Container $app, string $command, array $parameters)

Create a new pending console command run.

Parameters

TestCase $test
Container $app
string $command
array $parameters

Return Value

void

$this expectsQuestion(string $question, string|bool $answer)

Specify an expected question that will be asked when the command runs.

Parameters

string $question
string|bool $answer

Return Value

$this

$this expectsConfirmation(string $question, string $answer = 'no')

Specify an expected confirmation question that will be asked when the command runs.

Parameters

string $question
string $answer

Return Value

$this

$this expectsChoice(string $question, string|array $answer, array $answers, bool $strict = false)

Specify an expected choice question with expected answers that will be asked/shown when the command runs.

Parameters

string $question
string|array $answer
array $answers
bool $strict

Return Value

$this

$this expectsOutput(string $output)

Specify output that should be printed when the command runs.

Parameters

string $output

Return Value

$this

$this expectsTable(array $headers, Arrayable|array $rows, string $tableStyle = 'default', array $columnStyles = [])

Specify a table that should be printed when the command runs.

Parameters

array $headers
Arrayable|array $rows
string $tableStyle
array $columnStyles

Return Value

$this

$this assertExitCode(int $exitCode)

Assert that the command has the given exit code.

Parameters

int $exitCode

Return Value

$this

int execute()

Execute the command.

Return Value

int

int run()

Execute the command.

Return Value

int

Exceptions

NoMatchingExpectationException

protected void verifyExpectations()

Determine if expected questions / choices / outputs are fulfilled.

Return Value

void

protected MockInterface mockConsoleOutput()

Mock the application's console output.

Return Value

MockInterface

void __destruct()

Handle the object's destruction.

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/7.x/Illuminate/Testing/PendingCommand.html