BusFake
class BusFake implements Fake, QueueingDispatcher
Traits
Properties
| protected array | $jobsToFake | The job types that should be intercepted instead of dispatched. |
|
| protected array | $jobsToDispatch | The job types that should be dispatched instead of faked. |
|
| protected BatchRepository | $batchRepository | The fake repository to track batched jobs. |
|
| protected array | $commands | The commands that have been dispatched. |
|
| protected array | $commandsSync | The commands that have been dispatched synchronously. |
|
| protected array | $commandsAfterResponse | The commands that have been dispatched after the response has been sent. |
|
| protected array | $batches | The batches that have been dispatched. |
|
| protected bool | $serializeAndRestore | Indicates if commands should be serialized and restored when pushed to the Bus. |
Methods
Resolve a truth-test callback or an array of expected properties.
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Get the class names / types of the return type of the given Closure.
Create a new bus fake instance.
Specify the jobs that should be dispatched instead of faked.
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 that no jobs were dispatched.
Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
Assert if a job was pushed synchronously 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.
Assert if a chain of jobs was dispatched.
Assert no chained jobs was dispatched.
Reset the chain properties to their default values on the job.
Assert if a job was dispatched with an empty chain based on a truth-test callback.
Assert if a job was dispatched with chained jobs based on a truth-test callback.
Assert if a batch was dispatched based on a truth-test callback.
Assert the number of batches that have been dispatched.
Assert that no batched jobs were dispatched.
Assert that no jobs were dispatched, chained, or batched.
Get all of the jobs matching a truth-test callback.
Get all of the jobs dispatched synchronously matching a truth-test callback.
Get all of the jobs dispatched after the response was sent matching a truth-test callback.
Get all of the pending batches 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.
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 in the current process.
Dispatch a command to its appropriate handler behind a queue.
Dispatch a command to its appropriate handler after the current process.
Dispatch multiple commands in bulk to their appropriate handlers on the queue.
Create a new chain of queueable jobs.
Create a new batch of queueable jobs.
Dispatch an empty job batch for testing.
Determine if a command should be faked or actually dispatched.
Determine if a command should be dispatched or not.
Specify if commands should be serialized and restored when dispatched or batched.
Serialize and unserialize the command to simulate the queueing process.
Return the command representation that should be stored.
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.
Allow dispatching after responses.
Disable dispatching after responses.
Get the batches that have been dispatched.
Details
in
MatchesProperties at line 19
protected callable|null
resolveTruthTest(callable|array|null $callback)
Resolve a truth-test callback or an array of expected properties.
in
ReflectsClosures at line 26
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
in
ReflectsClosures at line 49
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
in
ReflectsClosures at line 75
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
in
ReflectsClosures at line 97
protected array
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
at line 72
__construct(QueueingDispatcher $dispatcher, array|string $jobsToFake = [], BatchRepository|null $batchRepository = null)
Create a new bus fake instance.
at line 86
BusFake
except(array|string $jobsToDispatch)
Specify the jobs that should be dispatched instead of faked.
at line 98
void
assertDispatched(Closure|string $command, callable|array|int|null $callback = null)
Assert if a job was dispatched based on a truth-test callback.
at line 120
void
assertDispatchedOnce(Closure|string $command)
Assert if a job was pushed exactly once.
at line 128
void
assertDispatchedTimes(Closure|string $command, int $times = 1)
Assert if a job was pushed a number of times.
at line 156
void
assertNotDispatched(Closure|string $command, callable|array|null $callback = null)
Determine if a job was dispatched based on a truth-test callback.
at line 173
void
assertNothingDispatched()
Assert that no jobs were dispatched.
at line 187
void
assertDispatchedSync(Closure|string $command, callable|array|int|null $callback = null)
Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
at line 207
void
assertDispatchedSyncTimes(Closure|string $command, int $times = 1)
Assert if a job was pushed synchronously a number of times.
at line 233
void
assertNotDispatchedSync(Closure|string $command, callable|array|null $callback = null)
Determine if a job was dispatched based on a truth-test callback.
at line 251
void
assertDispatchedAfterResponse(Closure|string $command, callable|array|int|null $callback = null)
Assert if a job was dispatched after the response was sent based on a truth-test callback.
at line 271
void
assertDispatchedAfterResponseTimes(Closure|string $command, int $times = 1)
Assert if a job was pushed after the response was sent a number of times.
at line 297
void
assertNotDispatchedAfterResponse(Closure|string $command, callable|array|null $callback = null)
Determine if a job was dispatched based on a truth-test callback.
at line 313
void
assertChained(array $expectedChain)
Assert if a chain of jobs was dispatched.
at line 350
void
assertNothingChained()
Assert no chained jobs was dispatched.
at line 358
protected mixed
resetChainPropertiesToDefaults(mixed $job)
Reset the chain properties to their default values on the job.
at line 373
void
assertDispatchedWithoutChain(Closure|string $command, callable|array|null $callback = null)
Assert if a job was dispatched with an empty chain based on a truth-test callback.
at line 394
protected void
assertDispatchedWithChainOfObjects(string $command, array $expectedChain, callable|array|null $callback)
Assert if a job was dispatched with chained jobs based on a truth-test callback.
at line 446
ChainedBatchTruthTest
chainedBatch(Closure $callback)
Create a new assertion about a chained batch.
at line 456
void
assertBatched(callable|array $callback)
Assert if a batch was dispatched based on a truth-test callback.
at line 469
void
assertBatchCount(int $count)
Assert the number of batches that have been dispatched.
at line 480
void
assertNothingBatched()
Assert that no batched jobs were dispatched.
at line 493
void
assertNothingPlaced()
Assert that no jobs were dispatched, chained, or batched.
at line 504
Collection
dispatched(string $command, callable|array|null $callback = null)
Get all of the jobs matching a truth-test callback.
at line 520
Collection
dispatchedSync(string $command, callable|array|null $callback = null)
Get all of the jobs dispatched synchronously matching a truth-test callback.
at line 536
Collection
dispatchedAfterResponse(string $command, callable|array|null $callback = null)
Get all of the jobs dispatched after the response was sent matching a truth-test callback.
at line 553
Collection
batched(callable $callback)
Get all of the pending batches matching a truth-test callback.
at line 565
bool
hasDispatched(string $command)
Determine if there are any stored commands for a given class.
at line 573
bool
hasDispatchedSync(string $command)
Determine if there are any stored commands for a given class.
at line 581
bool
hasDispatchedAfterResponse(string $command)
Determine if there are any stored commands for a given class.
at line 589
mixed
dispatch(mixed $command)
Dispatch a command to its appropriate handler.
at line 605
mixed
dispatchSync(mixed $command, mixed $handler = null)
Dispatch a command to its appropriate handler in the current process.
Queueable jobs will be dispatched to the "sync" queue.
at line 619
mixed
dispatchNow(mixed $command, mixed $handler = null)
Dispatch a command to its appropriate handler in the current process.
at line 633
mixed
dispatchToQueue(mixed $command)
Dispatch a command to its appropriate handler behind a queue.
at line 647
void
dispatchAfterResponse(mixed $command, mixed $handler = null)
Dispatch a command to its appropriate handler after the current process.
at line 660
void
bulk(iterable $jobs)
Dispatch multiple commands in bulk to their appropriate handlers on the queue.
at line 670
mixed
chain(mixed $jobs = null)
Create a new chain of queueable jobs.
at line 681
Batch|null
findBatch(string $batchId)
Attempt to find the batch with the given ID.
at line 689
PendingBatch
batch(mixed $jobs)
Create a new batch of queueable jobs.
at line 697
Batch
dispatchFakeBatch(string $name = '')
Dispatch an empty job batch for testing.
at line 705
Batch
recordPendingBatch(PendingBatch $pendingBatch)
Record the fake pending batch dispatch.
at line 721
protected bool
shouldFakeJob(mixed $command)
Determine if a command should be faked or actually dispatched.
at line 742
protected bool
shouldDispatchCommand(mixed $command)
Determine if a command should be dispatched or not.
at line 757
BusFake
serializeAndRestore(bool $serializeAndRestore = true)
Specify if commands should be serialized and restored when dispatched or batched.
at line 767
protected mixed
serializeAndRestoreCommand(mixed $command)
Serialize and unserialize the command to simulate the queueing process.
at line 775
protected mixed
getCommandRepresentation(mixed $command)
Return the command representation that should be stored.
at line 787
Dispatcher
pipeThrough(array $pipes)
Set the pipes commands should be piped through before dispatching.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 797
bool
hasCommandHandler(mixed $command)
Determine if the given command has a handler.
at line 805
mixed
getCommandHandler(mixed $command)
Retrieve the handler for a command.
at line 817
Dispatcher
map(array $map)
Map a command to a handler.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 831
BusFake
withDispatchingAfterResponses()
Allow dispatching after responses.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 845
BusFake
withoutDispatchingAfterResponses()
Disable dispatching after responses.
This changes the wrapped dispatcher, which is usually the application's worker-shared dispatcher.
at line 855
array
dispatchedBatches()
Get the batches that have been dispatched.