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 the given processes were run in the given order.
Assert how many processes have been recorded.
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 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.
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.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
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.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 342
mixed
__call(string $method, array $parameters)
Dynamically proxy methods to a new pending process instance.
at line 50
FakeProcessResult
result(array|string $output = '', array|string $errorOutput = '', int $exitCode = 0)
Create a new fake process response for testing purposes.
at line 62
FakeProcessDescription
describe()
Begin describing a fake process lifecycle.
at line 72
FakeProcessSequence
sequence(array $processes = [])
Begin describing a fake process sequence.
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.
at line 113
bool
isRecording()
Determine if the process factory has fake process handlers and is recording processes.
at line 123
Factory
recordIfRecording(PendingProcess $process, ProcessResult $result)
Record the given process if processes should be recorded.
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.
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.
at line 165
bool
preventingStrayProcesses()
Determine if stray processes are being prevented.
at line 176
Factory
assertRan(Closure|array|string $callback)
Assert that a process was recorded matching a given truth test.
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.
at line 219
Factory
assertRanInOrder(array $callbacks)
Assert that the given processes were run in the given order.
at line 242
protected Factory
assertRanCount(int $count)
Assert how many processes have been recorded.
at line 255
Factory
assertNotRan(Closure|array|string $callback)
Assert that a process was not recorded matching a given truth test.
at line 275
Factory
assertDidntRun(Closure|array|string $callback)
Assert that a process was not recorded matching a given truth test.
at line 285
Factory
assertNothingRan()
Assert that no processes were recorded.
at line 298
Pool
pool(callable $callback)
Start defining a pool of processes.
at line 306
ProcessResult
pipe(array|callable $callback, callable|null $output = null)
Start defining a series of piped processes.
at line 318
ProcessPoolResults
concurrently(callable $callback, callable|null $output = null)
Run a pool of processes and wait for them to finish executing.
at line 326
PendingProcess
newPendingProcess()
Create a new pending process associated with this factory.
at line 334
static void
flushState()
Flush all static state.