class PendingCommand

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected int|null $expectedExitCode

The expected exit code.

protected int|null $unexpectedExitCode

The unexpected exit code.

protected bool $hasExecuted

Determine if the command has executed.

Methods

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

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

Create a new pending console command run.

expectsQuestion(string $question, mixed $answer)

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

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

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

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

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

expectsSearch(string $question, array|string $answer, string $search, array $answers)

Specify an expected search question with an expected search string, followed by an expected choice question with expected answers.

expectsOutput(string|null $output = null)

Specify output that should be printed when the command runs.

doesntExpectOutput(string|null $output = null)

Specify output that should never be printed when the command runs.

expectsOutputToContain(string $string)

Specify that the given string should be contained in the command output.

doesntExpectOutputToContain(string $string)

Specify that the given string shouldn't be contained in the command output.

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

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

expectsPromptsInfo(string $message)

Specify that the given Prompts info message should be contained in the command output.

expectsPromptsWarning(string $message)

Specify that the given Prompts warning message should be contained in the command output.

expectsPromptsError(string $message)

Specify that the given Prompts error message should be contained in the command output.

expectsPromptsAlert(string $message)

Specify that the given Prompts alert message should be contained in the command output.

expectsPromptsIntro(string $message)

Specify that the given Prompts intro message should be contained in the command output.

expectsPromptsOutro(string $message)

Specify that the given Prompts outro message should be contained in the command output.

expectsPromptsTable(array|Collection $headers, array|Collection|null $rows)

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

void
expectOutputToContainPrompt(Prompt $prompt)

Render the given prompt and add the output to the expectations.

assertExitCode(int $exitCode)

Assert that the command has the given exit code.

assertNotExitCode(int $exitCode)

Assert that the command does not have the given exit code.

assertSuccessful()

Assert that the command has the success exit code.

assertOk()

Assert that the command has the success exit code.

assertFailed()

Assert that the command does not have the success exit code.

int
execute()

Execute the command.

int
run()

Execute the command.

never
dd()

Debug the command.

void
verifyExpectations()

Determine if expected questions / choices / outputs are fulfilled.

mockConsoleOutput()

Mock the application's console output.

void
flushExpectations()

Flush the expectations from the test case.

static void
flushState()

Flush all static state.

__destruct()

Handle the object's destruction.

Details

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Tappable at line 17
mixed tap(callable|null $callback = null)

Call the given Closure with this instance then return the instance.

Parameters

callable|null $callback

Return Value

mixed

at line 60
__construct(TestCase $test, Container $app, string $command, array $parameters)

Create a new pending console command run.

Parameters

TestCase $test

the test being run

Container $app

the application instance

string $command

the command to run

array $parameters

the parameters to pass to the command

at line 73
PendingCommand expectsQuestion(string $question, mixed $answer)

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

Parameters

string $question
mixed $answer

Return Value

PendingCommand

at line 85
PendingCommand 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

PendingCommand

at line 95
PendingCommand expectsChoice(string $question, array|string $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
array|string $answer
array $answers
bool $strict

Return Value

PendingCommand

at line 110
PendingCommand expectsSearch(string $question, array|string $answer, string $search, array $answers)

Specify an expected search question with an expected search string, followed by an expected choice question with expected answers.

Parameters

string $question
array|string $answer
string $search
array $answers

Return Value

PendingCommand

at line 122
PendingCommand expectsOutput(string|null $output = null)

Specify output that should be printed when the command runs.

Parameters

string|null $output

Return Value

PendingCommand

at line 140
PendingCommand doesntExpectOutput(string|null $output = null)

Specify output that should never be printed when the command runs.

Parameters

string|null $output

Return Value

PendingCommand

at line 158
PendingCommand expectsOutputToContain(string $string)

Specify that the given string should be contained in the command output.

Parameters

string $string

Return Value

PendingCommand

at line 170
PendingCommand doesntExpectOutputToContain(string $string)

Specify that the given string shouldn't be contained in the command output.

Parameters

string $string

Return Value

PendingCommand

at line 182
PendingCommand expectsTable(array $headers, array|Arrayable $rows, string $tableStyle = 'default', array $columnStyles = [])

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

Parameters

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

Return Value

PendingCommand

at line 211
PendingCommand expectsPromptsInfo(string $message)

Specify that the given Prompts info message should be contained in the command output.

Parameters

string $message

Return Value

PendingCommand

at line 225
PendingCommand expectsPromptsWarning(string $message)

Specify that the given Prompts warning message should be contained in the command output.

Parameters

string $message

Return Value

PendingCommand

at line 239
PendingCommand expectsPromptsError(string $message)

Specify that the given Prompts error message should be contained in the command output.

Parameters

string $message

Return Value

PendingCommand

at line 253
PendingCommand expectsPromptsAlert(string $message)

Specify that the given Prompts alert message should be contained in the command output.

Parameters

string $message

Return Value

PendingCommand

at line 267
PendingCommand expectsPromptsIntro(string $message)

Specify that the given Prompts intro message should be contained in the command output.

Parameters

string $message

Return Value

PendingCommand

at line 281
PendingCommand expectsPromptsOutro(string $message)

Specify that the given Prompts outro message should be contained in the command output.

Parameters

string $message

Return Value

PendingCommand

at line 299
PendingCommand expectsPromptsTable(array|Collection $headers, array|Collection|null $rows)

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

Parameters

array|Collection $headers
array|Collection|null $rows

Return Value

PendingCommand

at line 311
protected void expectOutputToContainPrompt(Prompt $prompt)

Render the given prompt and add the output to the expectations.

Parameters

Prompt $prompt

Return Value

void

at line 326
PendingCommand assertExitCode(int $exitCode)

Assert that the command has the given exit code.

Parameters

int $exitCode

Return Value

PendingCommand

at line 338
PendingCommand assertNotExitCode(int $exitCode)

Assert that the command does not have the given exit code.

Parameters

int $exitCode

Return Value

PendingCommand

at line 350
PendingCommand assertSuccessful()

Assert that the command has the success exit code.

Return Value

PendingCommand

at line 360
PendingCommand assertOk()

Assert that the command has the success exit code.

Return Value

PendingCommand

at line 370
PendingCommand assertFailed()

Assert that the command does not have the success exit code.

Return Value

PendingCommand

at line 378
int execute()

Execute the command.

Return Value

int

at line 388
int run()

Execute the command.

Return Value

int

Exceptions

NoMatchingExpectationException

at line 436
never dd()

Debug the command.

Return Value

never

at line 455
protected void verifyExpectations()

Determine if expected questions / choices / outputs are fulfilled.

Return Value

void

at line 493
protected mockConsoleOutput()

Mock the application's console output.

at line 608
protected void flushExpectations()

Flush the expectations from the test case.

Return Value

void

at line 622
static void flushState()

Flush all static state.

Return Value

void

at line 630
__destruct()

Handle the object's destruction.