class FakeProcessResult implements ProcessResult

Properties

protected string $output

The process output.

protected string $errorOutput

The process error output.

Methods

__construct(string $command = '', int $exitCode = 0, array|string $output = '', array|string $errorOutput = '')

Create a new process result instance.

string
normalizeOutput(array|string $output)

Normalize the given output into a string with newlines.

string
command()

Get the original command executed by the process.

withCommand(string $command)

Create a new fake process result with the given command.

bool
successful()

Determine if the process was successful.

bool
failed()

Determine if the process failed.

int|null
exitCode()

Get the exit code of the process.

string
output()

Get the standard output of the process.

bool
seeInOutput(string $output)

Determine if the output contains the given string.

string
errorOutput()

Get the error output of the process.

bool
seeInErrorOutput(string $output)

Determine if the error output contains the given string.

throw(callable|null $callback = null)

Throw an exception if the process failed.

throwIf(bool $condition, callable|null $callback = null)

Throw an exception if the process failed and the given condition is true.

Details

at line 31
__construct(string $command = '', int $exitCode = 0, array|string $output = '', array|string $errorOutput = '')

Create a new process result instance.

Parameters

string $command

the command string

int $exitCode

the process exit code

array|string $output

the process output

array|string $errorOutput

the process error output

at line 44
protected string normalizeOutput(array|string $output)

Normalize the given output into a string with newlines.

Parameters

array|string $output

Return Value

string

at line 63
string command()

Get the original command executed by the process.

Return Value

string

at line 71
FakeProcessResult withCommand(string $command)

Create a new fake process result with the given command.

Parameters

string $command

Return Value

FakeProcessResult

at line 79
bool successful()

Determine if the process was successful.

Return Value

bool

at line 87
bool failed()

Determine if the process failed.

Return Value

bool

at line 95
int|null exitCode()

Get the exit code of the process.

Return Value

int|null

at line 103
string output()

Get the standard output of the process.

Return Value

string

at line 111
bool seeInOutput(string $output)

Determine if the output contains the given string.

Parameters

string $output

Return Value

bool

at line 119
string errorOutput()

Get the error output of the process.

Return Value

string

at line 127
bool seeInErrorOutput(string $output)

Determine if the error output contains the given string.

Parameters

string $output

Return Value

bool

at line 137
ProcessResult throw(callable|null $callback = null)

Throw an exception if the process failed.

Parameters

callable|null $callback

Return Value

ProcessResult

Exceptions

ProcessFailedException

at line 157
ProcessResult throwIf(bool $condition, callable|null $callback = null)

Throw an exception if the process failed and the given condition is true.

Parameters

bool $condition
callable|null $callback

Return Value

ProcessResult

Exceptions

ProcessFailedException