class Factory (View source)

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 $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.

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.

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.

$this
fake(Closure|array $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(callable $callback)

Start defining a pool of processes.

pipe(callable|array $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.

Details

static void macro(string $name, object|callable $macro)

Register a custom macro.

Parameters

string $name
object|callable $macro

Return Value

void

static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

static bool hasMacro(string $name)

Checks if macro is registered.

Parameters

string $name

Return Value

bool

static void flushMacros()

Flush the existing macros.

Return Value

void

static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

mixed __call(string $method, array $parameters)

Dynamically proxy methods to a new pending process instance.

Parameters

string $method
array $parameters

Return Value

mixed

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

FakeProcessDescription describe()

Begin describing a fake process lifecycle.

Return Value

FakeProcessDescription

FakeProcessSequence sequence(array $processes = [])

Begin describing a fake process sequence.

Parameters

array $processes

Return Value

FakeProcessSequence

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

Indicate that the process factory should fake processes.

Parameters

Closure|array $callback

Return Value

$this

bool isRecording()

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

Return Value

bool

$this recordIfRecording(PendingProcess $process, ProcessResult $result)

Record the given process if processes should be recorded.

Parameters

PendingProcess $process
ProcessResult $result

Return Value

$this

$this record(PendingProcess $process, ProcessResult $result)

Record the given process.

Parameters

PendingProcess $process
ProcessResult $result

Return Value

$this

$this preventStrayProcesses(bool $prevent = true)

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

Parameters

bool $prevent

Return Value

$this

bool preventingStrayProcesses()

Determine if stray processes are being prevented.

Return Value

bool

$this assertRan(Closure|string $callback)

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

Parameters

Closure|string $callback

Return Value

$this

$this 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

$this

$this assertNotRan(Closure|string $callback)

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

Parameters

Closure|string $callback

Return Value

$this

$this assertDidntRun(Closure|string $callback)

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

Parameters

Closure|string $callback

Return Value

$this

$this assertNothingRan()

Assert that no processes were recorded.

Return Value

$this

Pool pool(callable $callback)

Start defining a pool of processes.

Parameters

callable $callback

Return Value

Pool

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

Start defining a series of piped processes.

Parameters

callable|array $callback
callable|null $output

Return Value

ProcessResult

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

PendingProcess newPendingProcess()

Create a new pending process associated with this factory.

Return Value

PendingProcess