class PendingCommand (View source)

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
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 int $unexpectedExitCode

The unexpected exit code.

protected bool $hasExecuted

Determine if the command has executed.

Methods

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

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

$this|TUnlessReturnType
unless($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, object|callable $macro)

Register a custom macro.

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

Mix another object into the class.

static bool
hasMacro(string $name)

Checks 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.

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
expectsSearch(string $question, string|array $answer, string $search, array $answers)

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

$this
expectsOutput(string|null $output = null)

Specify output that should be printed when the command runs.

$this
doesntExpectOutput(string|null $output = null)

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

$this
expectsOutputToContain(string $string)

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

$this
doesntExpectOutputToContain(string $string)

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

$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.

$this
assertNotExitCode(int $exitCode)

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

$this
assertSuccessful()

Assert that the command has the success exit code.

$this
assertOk()

Assert that the command has the success exit code.

$this
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.

MockInterface
mockConsoleOutput()

Mock the application's console output.

void
flushExpectations()

Flush the expectations from the test case.

void
__destruct()

Handle the object's destruction.

Details

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

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

Parameters

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

Return Value

$this|TWhenReturnType

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

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

Parameters

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

Return Value

$this|TUnlessReturnType

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

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

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

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

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

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

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 expectsSearch(string $question, string|array $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
string|array $answer
string $search
array $answers

Return Value

$this

$this expectsOutput(string|null $output = null)

Specify output that should be printed when the command runs.

Parameters

string|null $output

Return Value

$this

$this doesntExpectOutput(string|null $output = null)

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

Parameters

string|null $output

Return Value

$this

$this expectsOutputToContain(string $string)

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

Parameters

string $string

Return Value

$this

$this doesntExpectOutputToContain(string $string)

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

Parameters

string $string

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

$this assertNotExitCode(int $exitCode)

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

Parameters

int $exitCode

Return Value

$this

$this assertSuccessful()

Assert that the command has the success exit code.

Return Value

$this

$this assertOk()

Assert that the command has the success exit code.

Return Value

$this

$this assertFailed()

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

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

protected void flushExpectations()

Flush the expectations from the test case.

Return Value

void

void __destruct()

Handle the object's destruction.

Return Value

void