class Factory mixin PendingProcess

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected bool $recording

Indicates if the process factory has faked process handlers.

protected array<int, array> $recorded

All of the recorded processes.

protected Closure> $fakeHandlers

The registered fake handler callbacks.

protected bool $preventStrayProcesses

Indicates that an exception should be thrown if any process is not faked.

Methods

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 proxy methods to a new pending process instance.

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

Create a new fake process response for testing purposes.

describe()

Begin describing a fake process lifecycle.

sequence(array $processes = [])

Begin describing a fake process sequence.

fake(array|Closure|null $callback = null)

Indicate that the process factory should fake processes.

bool
isRecording()

Determine if the process factory has fake process handlers and is recording processes.

recordIfRecording(PendingProcess $process, ProcessResult $result)

Record the given process if processes should be recorded.

record(PendingProcess $process, ProcessResult $result)

Record the given process.

preventStrayProcesses(bool $prevent = true)

Indicate that an exception should be thrown if any process is not faked.

bool
preventingStrayProcesses()

Determine if stray processes are being prevented.

assertRan(Closure|string $callback)

Assert that a process was recorded matching a given truth test.

assertRanTimes(Closure|string $callback, int $times = 1)

Assert that a process was recorded a given number of times matching a given truth test.

assertNotRan(Closure|string $callback)

Assert that a process was not recorded matching a given truth test.

assertDidntRun(Closure|string $callback)

Assert that a process was not recorded matching a given truth test.

assertNothingRan()

Assert that no processes were recorded.

pool(callable $callback)

Start defining a pool of processes.

pipe(array|callable $callback, callable|null $output = null)

Start defining a series of piped processes.

concurrently(callable $callback, callable|null $output = null)

Run a pool of processes and wait for them to finish executing.

newPendingProcess()

Create a new pending process associated with this factory.

static void
flushState()

Flush all static state.

Details

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

at line 280
mixed __call(string $method, array $parameters)

Dynamically proxy methods to a new pending process instance.

Parameters

string $method
array $parameters

Return Value

mixed

at line 49
FakeProcessResult result(array|string $output = '', array|string $errorOutput = '', int $exitCode = 0)

Create a new fake process response for testing purposes.

Parameters

array|string $output
array|string $errorOutput
int $exitCode

Return Value

FakeProcessResult

at line 61
FakeProcessDescription describe()

Begin describing a fake process lifecycle.

Return Value

FakeProcessDescription

at line 71
FakeProcessSequence sequence(array $processes = [])

Begin describing a fake process sequence.

Parameters

array $processes

Return Value

FakeProcessSequence

at line 81
Factory fake(array|Closure|null $callback = null)

Indicate that the process factory should fake processes.

Tests only. Fake handlers and recordings persist on the container-resolved factory for the worker lifetime and affect later calls.

Parameters

array|Closure|null $callback

Return Value

Factory

at line 109
bool isRecording()

Determine if the process factory has fake process handlers and is recording processes.

Return Value

bool

at line 117
Factory recordIfRecording(PendingProcess $process, ProcessResult $result)

Record the given process if processes should be recorded.

Parameters

PendingProcess $process
ProcessResult $result

Return Value

Factory

at line 131
Factory record(PendingProcess $process, ProcessResult $result)

Record the given process.

Tests only. Recorded processes are retained on the worker factory and affect later assertions and memory retention.

Parameters

PendingProcess $process
ProcessResult $result

Return Value

Factory

at line 143
Factory preventStrayProcesses(bool $prevent = true)

Indicate that an exception should be thrown if any process is not faked.

Tests only. This setting persists on the worker factory and can reject every later unmatched process.

Parameters

bool $prevent

Return Value

Factory

at line 153
bool preventingStrayProcesses()

Determine if stray processes are being prevented.

Return Value

bool

at line 161
Factory assertRan(Closure|string $callback)

Assert that a process was recorded matching a given truth test.

Parameters

Closure|string $callback

Return Value

Factory

at line 178
Factory assertRanTimes(Closure|string $callback, int $times = 1)

Assert that a process was recorded a given number of times matching a given truth test.

Parameters

Closure|string $callback
int $times

Return Value

Factory

at line 198
Factory assertNotRan(Closure|string $callback)

Assert that a process was not recorded matching a given truth test.

Parameters

Closure|string $callback

Return Value

Factory

at line 215
Factory assertDidntRun(Closure|string $callback)

Assert that a process was not recorded matching a given truth test.

Parameters

Closure|string $callback

Return Value

Factory

at line 223
Factory assertNothingRan()

Assert that no processes were recorded.

Return Value

Factory

at line 236
Pool pool(callable $callback)

Start defining a pool of processes.

Parameters

callable $callback

Return Value

Pool

at line 244
ProcessResult pipe(array|callable $callback, callable|null $output = null)

Start defining a series of piped processes.

Parameters

array|callable $callback
callable|null $output

Return Value

ProcessResult

at line 256
ProcessPoolResults concurrently(callable $callback, callable|null $output = null)

Run a pool of processes and wait for them to finish executing.

Parameters

callable $callback
callable|null $output

Return Value

ProcessPoolResults

at line 264
PendingProcess newPendingProcess()

Create a new pending process associated with this factory.

Return Value

PendingProcess

at line 272
static void flushState()

Flush all static state.

Return Value

void