Factory
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
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically proxy methods to a new pending process instance.
Create a new fake process response for testing purposes.
Begin describing a fake process lifecycle.
Begin describing a fake process sequence.
Determine if the process factory has fake process handlers and is recording processes.
Record the given process if processes should be recorded.
Indicate that an exception should be thrown if any process is not faked.
Determine if stray processes are being prevented.
Assert that a process was recorded a given number of times matching a given truth test.
Assert that a process was not recorded matching a given truth test.
Assert that a process was not recorded matching a given truth test.
Assert that no processes were recorded.
Start defining a series of piped processes.
Run a pool of processes and wait for them to finish executing.
Create a new pending process associated with this factory.
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.
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.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
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.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 280
mixed
__call(string $method, array $parameters)
Dynamically proxy methods to a new pending process instance.
at line 49
FakeProcessResult
result(array|string $output = '', array|string $errorOutput = '', int $exitCode = 0)
Create a new fake process response for testing purposes.
at line 61
FakeProcessDescription
describe()
Begin describing a fake process lifecycle.
at line 71
FakeProcessSequence
sequence(array $processes = [])
Begin describing a fake process sequence.
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.
at line 109
bool
isRecording()
Determine if the process factory has fake process handlers and is recording processes.
at line 117
Factory
recordIfRecording(PendingProcess $process, ProcessResult $result)
Record the given process if processes should be recorded.
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.
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.
at line 153
bool
preventingStrayProcesses()
Determine if stray processes are being prevented.
at line 161
Factory
assertRan(Closure|string $callback)
Assert that a process was recorded matching a given truth test.
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.
at line 198
Factory
assertNotRan(Closure|string $callback)
Assert that a process was not recorded matching a given truth test.
at line 215
Factory
assertDidntRun(Closure|string $callback)
Assert that a process was not recorded matching a given truth test.
at line 223
Factory
assertNothingRan()
Assert that no processes were recorded.
at line 236
Pool
pool(callable $callback)
Start defining a pool of processes.
at line 244
ProcessResult
pipe(array|callable $callback, callable|null $output = null)
Start defining a series of piped processes.
at line 256
ProcessPoolResults
concurrently(callable $callback, callable|null $output = null)
Run a pool of processes and wait for them to finish executing.
at line 264
PendingProcess
newPendingProcess()
Create a new pending process associated with this factory.
at line 272
static void
flushState()
Flush all static state.