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, array|bool|string $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.

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 15
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 57
__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 68
PendingCommand expectsQuestion(string $question, array|bool|string $answer)

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

Parameters

string $question
array|bool|string $answer

Return Value

PendingCommand

at line 78
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 86
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 99
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 109
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 125
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 141
PendingCommand expectsOutputToContain(string $string)

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

Parameters

string $string

Return Value

PendingCommand

at line 151
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 161
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 188
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 200
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 212
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 224
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 236
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 248
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 265
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 277
protected void expectOutputToContainPrompt(Prompt $prompt)

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

Parameters

Prompt $prompt

Return Value

void

at line 290
PendingCommand assertExitCode(int $exitCode)

Assert that the command has the given exit code.

Parameters

int $exitCode

Return Value

PendingCommand

at line 300
PendingCommand assertNotExitCode(int $exitCode)

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

Parameters

int $exitCode

Return Value

PendingCommand

at line 310
PendingCommand assertSuccessful()

Assert that the command has the success exit code.

Return Value

PendingCommand

at line 318
PendingCommand assertOk()

Assert that the command has the success exit code.

Return Value

PendingCommand

at line 326
PendingCommand assertFailed()

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

Return Value

PendingCommand

at line 334
int execute()

Execute the command.

Return Value

int

at line 344
int run()

Execute the command.

Return Value

int

Exceptions

NoMatchingExpectationException

at line 389
protected void verifyExpectations()

Determine if expected questions / choices / outputs are fulfilled.

Return Value

void

at line 427
protected mockConsoleOutput()

Mock the application's console output.

at line 540
protected void flushExpectations()

Flush the expectations from the test case.

Return Value

void

at line 554
static void flushState()

Flush all static state.

Return Value

void

at line 562
__destruct()

Handle the object's destruction.