BusFake
class BusFake implements QueueingDispatcher (View source)
Traits
Properties
protected QueueingDispatcher | $dispatcher | The original Bus dispatcher implementation. |
|
protected array | $jobsToFake | The job types that should be intercepted instead of dispatched. |
|
protected array | $commands | The commands that have been dispatched. |
|
protected array | $commandsAfterResponse | The commands that have been dispatched after the response has been sent. |
Methods
Get the class names / types of the parameters of the given Closure.
Get the class name of the first parameter of the given Closure.
Create a new bus fake instance.
Assert if a job was dispatched based on a truth-test callback.
Assert if a job was pushed a number of times.
Determine if a job was dispatched based on a truth-test callback.
Assert if a job was dispatched after the response was sent based on a truth-test callback.
Assert if a job was pushed after the response was sent a number of times.
Determine if a job was dispatched based on a truth-test callback.
Get all of the jobs matching a truth-test callback.
Get all of the jobs dispatched after the response was sent matching a truth-test callback.
Determine if there are any stored commands for a given class.
Determine if there are any stored commands for a given class.
Dispatch a command to its appropriate handler.
Dispatch a command to its appropriate handler in the current process.
Dispatch a command to its appropriate handler behind a queue.
Dispatch a command to its appropriate handler.
Determine if an command should be faked or actually dispatched.
Set the pipes commands should be piped through before dispatching.
Determine if the given command has a handler.
Retrieve the handler for a command.
Map a command to a handler.
Details
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
void
__construct(QueueingDispatcher $dispatcher, array|string $jobsToFake = [])
Create a new bus fake instance.
void
assertDispatched(string|Closure $command, callable|int|null $callback = null)
Assert if a job was dispatched based on a truth-test callback.
void
assertDispatchedTimes(string $command, int $times = 1)
Assert if a job was pushed a number of times.
void
assertNotDispatched(string|Closure $command, callable|null $callback = null)
Determine if a job was dispatched based on a truth-test callback.
void
assertDispatchedAfterResponse(string|Closure $command, callable|int|null $callback = null)
Assert if a job was dispatched after the response was sent based on a truth-test callback.
void
assertDispatchedAfterResponseTimes(string $command, int $times = 1)
Assert if a job was pushed after the response was sent a number of times.
void
assertNotDispatchedAfterResponse(string|Closure $command, callable|null $callback = null)
Determine if a job was dispatched based on a truth-test callback.
Collection
dispatched(string $command, callable|null $callback = null)
Get all of the jobs matching a truth-test callback.
Collection
dispatchedAfterResponse(string $command, callable|null $callback = null)
Get all of the jobs dispatched after the response was sent matching a truth-test callback.
bool
hasDispatched(string $command)
Determine if there are any stored commands for a given class.
bool
hasDispatchedAfterResponse(string $command)
Determine if there are any stored commands for a given class.
mixed
dispatch(mixed $command)
Dispatch a command to its appropriate handler.
mixed
dispatchNow(mixed $command, mixed $handler = null)
Dispatch a command to its appropriate handler in the current process.
mixed
dispatchToQueue(mixed $command)
Dispatch a command to its appropriate handler behind a queue.
mixed
dispatchAfterResponse(mixed $command)
Dispatch a command to its appropriate handler.
protected bool
shouldFakeJob(mixed $command)
Determine if an command should be faked or actually dispatched.
$this
pipeThrough(array $pipes)
Set the pipes commands should be piped through before dispatching.
bool
hasCommandHandler(mixed $command)
Determine if the given command has a handler.
bool|mixed
getCommandHandler(mixed $command)
Retrieve the handler for a command.
$this
map(array $map)
Map a command to a handler.