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 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. 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 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. 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 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

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

Return Value

void

in Macroable at line 78
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 103
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 71
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 81
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 89
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 102
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 112
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 128
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 144
PendingCommand expectsOutputToContain(string $string)

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

Parameters

string $string

Return Value

PendingCommand

at line 154
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 164
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 191
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 203
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 215
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 227
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 239
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 251
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 268
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 280
protected void expectOutputToContainPrompt(Prompt $prompt)

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

Parameters

Prompt $prompt

Return Value

void

at line 293
PendingCommand assertExitCode(int $exitCode)

Assert that the command has the given exit code.

Parameters

int $exitCode

Return Value

PendingCommand

at line 303
PendingCommand assertNotExitCode(int $exitCode)

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

Parameters

int $exitCode

Return Value

PendingCommand

at line 313
PendingCommand assertSuccessful()

Assert that the command has the success exit code.

Return Value

PendingCommand

at line 321
PendingCommand assertOk()

Assert that the command has the success exit code.

Return Value

PendingCommand

at line 329
PendingCommand assertFailed()

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

Return Value

PendingCommand

at line 337
int execute()

Execute the command.

Return Value

int

at line 347
int run()

Execute the command.

Return Value

int

Exceptions

NoMatchingExpectationException

at line 395
never dd()

Debug the command.

Return Value

never

at line 414
protected void verifyExpectations()

Determine if expected questions / choices / outputs are fulfilled.

Return Value

void

at line 452
protected mockConsoleOutput()

Mock the application's console output.

at line 569
protected void flushExpectations()

Flush the expectations from the test case.

Return Value

void

at line 583
static void flushState()

Flush all static state.

Return Value

void

at line 591
__destruct()

Handle the object's destruction.