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|array|string $callback)

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

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

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

assertRanInOrder(array $callbacks)

Assert that the given processes were run in the given order.

assertRanCount(int $count)

Assert how many processes have been recorded.

assertNotRan(Closure|array|string $callback)

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

assertDidntRun(Closure|array|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 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

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

Mix another object into the class.

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 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

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

Return Value

void

in Macroable at line 83
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 342
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 50
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 62
FakeProcessDescription describe()

Begin describing a fake process lifecycle.

Return Value

FakeProcessDescription

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

Begin describing a fake process sequence.

Parameters

array $processes

Return Value

FakeProcessSequence

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

Indicate that the process factory should fake processes.

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 113
bool isRecording()

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

Return Value

bool

at line 123
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 139
Factory record(PendingProcess $process, ProcessResult $result)

Record the given process.

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 154
Factory preventStrayProcesses(bool $prevent = true)

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

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

Parameters

bool $prevent

Return Value

Factory

at line 165
bool preventingStrayProcesses()

Determine if stray processes are being prevented.

Return Value

bool

at line 176
Factory assertRan(Closure|array|string $callback)

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

Parameters

Closure|array|string $callback

Return Value

Factory

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

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

Parameters

Closure|array|string $callback
int $times

Return Value

Factory

at line 219
Factory assertRanInOrder(array $callbacks)

Assert that the given processes were run in the given order.

Parameters

array $callbacks

Return Value

Factory

at line 242
protected Factory assertRanCount(int $count)

Assert how many processes have been recorded.

Parameters

int $count

Return Value

Factory

at line 255
Factory assertNotRan(Closure|array|string $callback)

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

Parameters

Closure|array|string $callback

Return Value

Factory

at line 275
Factory assertDidntRun(Closure|array|string $callback)

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

Parameters

Closure|array|string $callback

Return Value

Factory

at line 285
Factory assertNothingRan()

Assert that no processes were recorded.

Return Value

Factory

at line 298
Pool pool(callable $callback)

Start defining a pool of processes.

Parameters

callable $callback

Return Value

Pool

at line 306
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 318
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 326
PendingProcess newPendingProcess()

Create a new pending process associated with this factory.

Return Value

PendingProcess

at line 334
static void flushState()

Flush all static state.

Return Value

void