BusFake
Implements
Uses
Properties
$jobsToFake array
The job types that should be intercepted instead of dispatched.
$jobsToDispatch array
The job types that should be dispatched instead of faked.
$commands array
The commands that have been dispatched.
$commandsSync array
The commands that have been dispatched synchronously.
$commandsAfterResponse array
The commands that have been dispatched after the response has been sent.
$batches array
The batches that have been dispatched.
Methods
__construct ( QueueingDispatcher $dispatcher , $jobsToFake , BatchRepository $batchRepository ) : void
Create a new bus fake instance.
Parameters
- $dispatcher QueueingDispatcher
- $jobsToFake array|string
- $batchRepository BatchRepository |null
except ( $jobsToDispatch ) : $this
Specify the jobs that should be dispatched instead of faked.
Parameters
- $jobsToDispatch array|string
assertDispatched ( $command , $callback ) : void
Assert if a job was dispatched based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|int|null
assertDispatchedTimes ( $command , $times ) : void
Assert if a job was pushed a number of times.
Parameters
- $command string|Closure
- $times int
assertNotDispatched ( $command , $callback ) : void
Determine if a job was dispatched based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|null
assertNothingDispatched ( ) : void
Assert that no jobs were dispatched.
assertDispatchedSync ( $command , $callback ) : void
Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|int|null
assertDispatchedSyncTimes ( $command , $times ) : void
Assert if a job was pushed synchronously a number of times.
Parameters
- $command string|Closure
- $times int
assertNotDispatchedSync ( $command , $callback ) : void
Determine if a job was dispatched based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|null
assertDispatchedAfterResponse ( $command , $callback ) : void
Assert if a job was dispatched after the response was sent based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|int|null
assertDispatchedAfterResponseTimes ( $command , $times ) : void
Assert if a job was pushed after the response was sent a number of times.
Parameters
- $command string|Closure
- $times int
assertNotDispatchedAfterResponse ( $command , $callback ) : void
Determine if a job was dispatched based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|null
assertChained ( array $expectedChain ) : void
Assert if a chain of jobs was dispatched.
Parameters
- $expectedChain array
resetChainPropertiesToDefaults ( $job ) : mixed
Reset the chain properties to their default values on the job.
Parameters
- $job mixed
assertDispatchedWithoutChain ( $command , $callback ) : void
Assert if a job was dispatched with an empty chain based on a truth-test callback.
Parameters
- $command string|Closure
- $callback callable|null
assertDispatchedWithChainOfObjects ( $command , $expectedChain , $callback ) : void
Assert if a job was dispatched with chained jobs based on a truth-test callback.
Parameters
- $command string
- $expectedChain array
- $callback callable|null
assertDispatchedWithChainOfClasses ( $command , $expectedChain , $callback ) : void
Assert if a job was dispatched with chained jobs based on a truth-test callback.
Parameters
- $command string
- $expectedChain array
- $callback callable|null
isChainOfObjects ( $chain ) : bool
Determine if the given chain is entirely composed of objects.
Parameters
- $chain array
assertBatched ( callable $callback ) : void
Assert if a batch was dispatched based on a truth-test callback.
Parameters
- $callback callable
assertBatchCount ( $count ) : void
Assert the number of batches that have been dispatched.
Parameters
- $count int
assertNothingBatched ( ) : void
Assert that no batched jobs were dispatched.
dispatched ( $command , $callback ) : Illuminate\...\Collection
Get all of the jobs matching a truth-test callback.
Parameters
- $command string
- $callback callable|null
dispatchedSync ( string $command , $callback ) : Illuminate\...\Collection
Get all of the jobs dispatched synchronously matching a truth-test callback.
Parameters
- $command string
- $callback callable|null
dispatchedAfterResponse ( string $command , $callback ) : Illuminate\...\Collection
Get all of the jobs dispatched after the response was sent matching a truth-test callback.
Parameters
- $command string
- $callback callable|null
batched ( callable $callback ) : Illuminate\...\Collection
Get all of the pending batches matching a truth-test callback.
Parameters
- $callback callable
hasDispatched ( $command ) : bool
Determine if there are any stored commands for a given class.
Parameters
- $command string
hasDispatchedSync ( $command ) : bool
Determine if there are any stored commands for a given class.
Parameters
- $command string
hasDispatchedAfterResponse ( $command ) : bool
Determine if there are any stored commands for a given class.
Parameters
- $command string
dispatch ( $command ) : mixed
Dispatch a command to its appropriate handler.
Parameters
- $command mixed
dispatchSync ( $command , $handler ) : mixed
Dispatch a command to its appropriate handler in the current process.
Parameters
- $command mixed
- $handler mixed
dispatchNow ( $command , $handler ) : mixed
Dispatch a command to its appropriate handler in the current process.
Parameters
- $command mixed
- $handler mixed
dispatchToQueue ( $command ) : mixed
Dispatch a command to its appropriate handler behind a queue.
Parameters
- $command mixed
dispatchAfterResponse ( $command ) : mixed
Dispatch a command to its appropriate handler.
Parameters
- $command mixed
chain ( $jobs ) : PendingChain
Create a new chain of queueable jobs.
Parameters
- $jobs Illuminate\...\Collection|array
findBatch ( string $batchId ) : Batch |null
Attempt to find the batch with the given ID.
Parameters
- $batchId string
batch ( $jobs ) : PendingBatch
Create a new batch of queueable jobs.
Parameters
- $jobs Illuminate\...\Collection|array
dispatchFakeBatch ( $name ) : Batch
Dispatch an empty job batch for testing.
Parameters
- $name string
recordPendingBatch ( PendingBatch $pendingBatch ) : Batch
Record the fake pending batch dispatch.
Parameters
- $pendingBatch PendingBatch
shouldFakeJob ( $command ) : bool
Determine if a command should be faked or actually dispatched.
Parameters
- $command mixed
shouldDispatchCommand ( $command ) : bool
Determine if a command should be dispatched or not.
Parameters
- $command mixed
pipeThrough ( array $pipes ) : $this
Set the pipes commands should be piped through before dispatching.
Parameters
- $pipes array
hasCommandHandler ( $command ) : bool
Determine if the given command has a handler.
Parameters
- $command mixed
getCommandHandler ( $command ) : mixed
Retrieve the handler for a command.
Parameters
- $command mixed
map ( array $map ) : $this
Map a command to a handler.
Parameters
- $map array