Factory
class Factory (View source)
Traits
| Macroable |
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 | $recorded | All of the recorded processes. | |
| protected array | $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, object|callable $macro)
Register a custom macro. | from Macroable |
| static void | mixin(object $mixin, bool $replace = true)
Mix another object into the class. | from Macroable |
| static bool | hasMacro(string $name)
Checks if macro is registered. | from Macroable |
| static void | flushMacros()
Flush the existing macros. | from Macroable |
| static mixed | __callStatic(string $method, array $parameters)
Dynamically handle calls to the class. | from Macroable |
| mixed | __call(string $method, array $parameters)
Dynamically proxy methods to a new pending process instance. | |
| FakeProcessResult | result(array|string $output = '', array|string $errorOutput = '', int $exitCode = 0)
Create a new fake process response for testing purposes. | |
| FakeProcessDescription | describe()
Begin describing a fake process lifecycle. | |
| FakeProcessSequence | sequence(array $processes = [])
Begin describing a fake process sequence. | |
| $this | fake(Closure|array|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. | |
| $this | recordIfRecording(PendingProcess $process, ProcessResult $result)
Record the given process if processes should be recorded. | |
| $this | record(PendingProcess $process, ProcessResult $result)
Record the given process. | |
| $this | 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. | |
| $this | assertRan(Closure|string $callback)
Assert that a process was recorded matching a given truth test. | |
| $this | assertRanTimes(Closure|string $callback, int $times = 1)
Assert that a process was recorded a given number of times matching a given truth test. | |
| $this | assertNotRan(Closure|string $callback)
Assert that a process was not recorded matching a given truth test. | |
| $this | assertDidntRun(Closure|string $callback)
Assert that a process was not recorded matching a given truth test. | |
| $this | assertNothingRan()
Assert that no processes were recorded. | |
| Pool | pool(callable $callback)
Start defining a pool of processes. | |
| ProcessResult | pipe(callable|array $callback, callable|null $output = null)
Start defining a series of piped processes. | |
| ProcessPoolResults | concurrently(callable $callback, callable|null $output = null)
Run a pool of processes and wait for them to finish executing. | |
| PendingProcess | newPendingProcess()
Create a new pending process associated with this factory. |
Details
static void macro(string $name, object|callable $macro)
Register a custom macro.
static void mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool hasMacro(string $name)
Checks 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.
FakeProcessResult result(array|string $output = '', array|string $errorOutput = '', int $exitCode = 0)
Create a new fake process response for testing purposes.
FakeProcessDescription describe()
Begin describing a fake process lifecycle.
FakeProcessSequence sequence(array $processes = [])
Begin describing a fake process sequence.
$this fake(Closure|array|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.
$this recordIfRecording(PendingProcess $process, ProcessResult $result)
Record the given process if processes should be recorded.
$this record(PendingProcess $process, ProcessResult $result)
Record the given process.
$this 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.
$this assertRan(Closure|string $callback)
Assert that a process was recorded matching a given truth test.
$this assertRanTimes(Closure|string $callback, int $times = 1)
Assert that a process was recorded a given number of times matching a given truth test.
$this assertNotRan(Closure|string $callback)
Assert that a process was not recorded matching a given truth test.
$this assertDidntRun(Closure|string $callback)
Assert that a process was not recorded matching a given truth test.
$this assertNothingRan()
Assert that no processes were recorded.
Pool pool(callable $callback)
Start defining a pool of processes.
ProcessResult pipe(callable|array $callback, callable|null $output = null)
Start defining a series of piped processes.
ProcessPoolResults concurrently(callable $callback, callable|null $output = null)
Run a pool of processes and wait for them to finish executing.
PendingProcess newPendingProcess()
Create a new pending process associated with this factory.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Process/Factory.html