QueueFake
class QueueFake extends QueueManager implements Fake, Queue
Traits
Properties
| protected Closure> | $releaseCallbacks | from HasPoolProxy | |
| protected array | $connections | The array of resolved queue connections. |
from QueueManager |
| protected array | $connectors | The array of resolved queue connectors. |
from QueueManager |
| protected array | $poolables | The array of drivers which will be wrapped as pool proxies. |
from QueueManager |
| Factory|null | $queue | The original queue manager. |
|
| protected Collection | $jobsToFake | The job types that should be intercepted instead of pushed to the queue. |
|
| protected Collection | $jobsToBeQueued | The job types that should be pushed to the queue and not intercepted. |
|
| protected array | $jobs | All of the jobs that have been pushed. |
|
| protected RawPushType> | $rawPushes | All of the payloads that have been raw pushed. |
|
| protected array | $uniqueJobs | All of the unique jobs that were pushed. |
|
| protected array | $reserved | All of the jobs that have been marked as reserved. |
|
| protected bool | $serializeAndRestore | Indicates if items should be serialized and restored when pushed to the queue. |
|
| protected array<int, callable> | $beforePushingCallbacks | The callbacks that should be invoked before pushing a job. |
|
| protected array<int, callable> | $afterPushingCallbacks | The callbacks that should be invoked after pushing a job. |
Methods
Create a pool proxy for an immutable definition.
Build a namespaced pool definition for a pooled resource.
Get the release callback for a pooled driver.
Add a driver to the poolable-driver list.
Remove a driver from the poolable-driver list.
Resolve the default connection name for a given queueable instance.
Resolve the default queue name for a given queueable instance.
Create a new fake queue instance.
Register an event listener for the exception occurred job event.
Register an event listener for the daemon queue loop.
Register an event listener for the failed job event.
Register an event listener for the daemon queue starting.
Register an event listener for the daemon queue stopping.
Register the default queue route for a given class.
Pause a queue by its connection and name.
Pause a queue by its connection and name for a given amount of time.
Resume a paused queue by its connection and name.
Determine which of the given queues are currently paused.
Indicate that queue workers should not poll for restart or pause signals.
Determine if the driver is connected.
Resolve a queue connection instance.
Get the connector for a given driver.
Set the name of the default queue connection.
Get the full name for the given connection.
Disconnect a queue connection and close its shared resource pool.
Override the QueueManager to prevent circular dependency.
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.
Specify the jobs that should be queued instead of faked.
Assert if a job was pushed based on a truth-test callback.
Assert if a job was pushed a number of times.
Assert if a job was pushed exactly once.
Assert if a job was pushed based on a truth-test callback.
Assert if a job was pushed with chained jobs based on a truth-test callback.
Assert if a job was pushed with an empty chain based on a truth-test callback.
Assert if a job was pushed with chained jobs based on a truth-test callback.
Assert if a job was pushed with chained jobs based on a truth-test callback.
Assert if a closure was pushed based on a truth-test callback.
Assert that a closure was not pushed based on a truth-test callback.
Determine if the given chain is entirely composed of objects.
Determine if a job was pushed based on a truth-test callback.
Assert the total count of jobs that were pushed.
Assert that no jobs were pushed.
Get all of the jobs matching a truth-test callback.
Get all of the jobs by listener class, passing an optional truth-test callback.
Determine if there are any stored jobs for a given class.
Get the size of the queue.
Get the number of pending jobs.
Get the number of delayed jobs.
Get the number of reserved jobs.
Get the pending jobs for the given queue.
Get the delayed jobs for the given queue.
Get the reserved jobs for the given queue.
Get all pending jobs across every queue.
Get all delayed jobs across every queue.
Get all reserved jobs across every queue.
Map an array of jobs to a collection of inspected jobs.
Get pushed jobs classified by their delay.
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
Push a new job onto the queue.
Push a job through the fake or its underlying queue.
Determine if a job should be faked or actually dispatched.
Determine if a job should be pushed to the queue instead of faked.
Push a raw payload onto the queue.
Push a new job onto the queue after (n) seconds.
Push a new job onto the queue.
Push a new job onto a specific queue after (n) seconds.
Record the given job as reserved.
Push an array of jobs onto the queue.
Get the jobs that have been pushed.
Get the payloads that were pushed raw.
Specify if jobs should be serialized and restored when being "pushed" to the queue.
Serialize and unserialize the job to simulate the queueing process.
Release the locks for all unique jobs that were pushed.
Clear all of the reserved jobs.
Register a callback to be invoked before pushing a job.
Register a callback to be invoked after pushing a job.
Normalize a queue identifier.
Get the connection name for the queue.
Set the connection name for the queue.
Details
in
HasPoolProxy at line 24
protected mixed
createPoolProxy(string $driver, Closure $resolver, PoolDefinition $definition, string $proxyClass)
Create a pool proxy for an immutable definition.
in
HasPoolProxy at line 45
protected PoolDefinition
poolDefinition(string $resource, array $poolConfig, array $fingerprintSource)
Build a namespaced pool definition for a pooled resource.
in
HasPoolProxy at line 63
abstract protected Factory
poolFactory()
Get the pool factory used by this manager.
in
HasPoolProxy at line 71
HasPoolProxy
setReleaseCallback(string $driver, Closure $callback)
Set the release callback for a pooled driver.
Boot-only. The callback persists on the manager for the worker lifetime and is captured by every subsequently created proxy for the driver.
in
HasPoolProxy at line 81
Closure|null
getReleaseCallback(string $driver)
Get the release callback for a pooled driver.
in
HasPoolProxy at line 93
HasPoolProxy
addPoolable(string $driver)
Add a driver to the poolable-driver list.
Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
HasPoolProxy at line 109
HasPoolProxy
removePoolable(string $driver)
Remove a driver from the poolable-driver list.
Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
HasPoolProxy at line 126
array
getPoolables()
Get the poolable-driver list.
in
HasPoolProxy at line 138
HasPoolProxy
setPoolables(array $poolables)
Set the poolable-driver list.
Boot-only. The list persists on the manager for the worker lifetime and is consulted on subsequent driver creation. Per-request use races across coroutines and does not affect already-cached drivers.
in
ResolvesQueueRoutes at line 15
string|null
resolveConnectionFromQueueRoute(object $queueable)
Resolve the default connection name for a given queueable instance.
in
ResolvesQueueRoutes at line 23
string|null
resolveQueueFromQueueRoute(object $queueable)
Resolve the default queue name for a given queueable instance.
in
ResolvesQueueRoutes at line 31
protected QueueRoutes
queueRoutes()
Get the queue routes manager instance.
at line 97
__construct(Container $app, array|string $jobsToFake = [], Factory|null $queue = null)
Create a new fake queue instance.
in
QueueManager at line 61
void
before(mixed $callback)
Register an event listener for the before job event.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 73
void
after(mixed $callback)
Register an event listener for the after job event.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 85
void
exceptionOccurred(mixed $callback)
Register an event listener for the exception occurred job event.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 97
void
looping(mixed $callback)
Register an event listener for the daemon queue loop.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 109
void
failing(mixed $callback)
Register an event listener for the failed job event.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 121
void
starting(mixed $callback)
Register an event listener for the daemon queue starting.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 133
void
stopping(mixed $callback)
Register an event listener for the daemon queue stopping.
Boot-only. The listener persists on the singleton event dispatcher for the worker lifetime and runs for every subsequent matching queue event.
in
QueueManager at line 147
void
route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)
Register the default queue route for a given class.
Boot-only. The route persists on the singleton QueueRoutes registry for the worker lifetime and affects every subsequent dispatch of that class.
in
QueueManager at line 155
void
pause(string $connection, string $queue)
Pause a queue by its connection and name.
in
QueueManager at line 170
void
pauseFor(string $connection, string $queue, DateInterval|DateTimeInterface|int $ttl)
Pause a queue by its connection and name for a given amount of time.
in
QueueManager at line 185
void
resume(string $connection, string $queue)
Resume a paused queue by its connection and name.
in
QueueManager at line 200
bool
isPaused(string $connection, string $queue)
Determine if a queue is paused.
in
QueueManager at line 211
array
getPausedQueues(string $connection, array $queues)
Determine which of the given queues are currently paused.
in
QueueManager at line 232
void
withoutInterruptionPolling()
Indicate that queue workers should not poll for restart or pause signals.
Boot-only. Mutates process-global worker flags; runtime use races across coroutines and changes every concurrent worker pause or restart check.
in
QueueManager at line 241
bool
connected(UnitEnum|string|null $name = null)
Determine if the driver is connected.
at line 377
Queue
connection(mixed $value = null)
Resolve a queue connection instance.
in
QueueManager at line 282
protected Queue
resolve(string $name)
Resolve a queue connection.
in
QueueManager at line 316
protected ConnectorInterface
getConnector(string $driver)
Get the connector for a given driver.
in
QueueManager at line 331
void
extend(string $driver, Closure $resolver)
Add a queue connection resolver.
Boot-only. The resolver persists in the singleton's connectors array for the worker lifetime and applies to every subsequent connection.
in
QueueManager at line 342
void
addConnector(string $driver, Closure $resolver)
Add a queue connection resolver.
Boot-only. The resolver persists in the singleton's connectors array for the worker lifetime and applies to every subsequent connection.
in
QueueManager at line 350
protected array|null
getConfig(string $name)
Get the queue connection configuration.
in
QueueManager at line 370
string
getDefaultDriver()
Get the name of the default queue connection.
in
QueueManager at line 380
void
setDefaultDriver(UnitEnum|string $name)
Set the name of the default queue connection.
Boot-only. Mutates process-global config; per-request use races across coroutines.
in
QueueManager at line 390
string
getName(string|null $connection = null)
Get the full name for the given connection.
in
QueueManager at line 404
void
purge(string|null $name = null)
Disconnect a queue connection and close its shared resource pool.
Boot or tests only, plus operational recovery of broken pooled resources. Other connections sharing the pool transparently acquire a fresh pool on their next operation.
in
QueueManager at line 440
Container
getApplication()
Get the application instance used by the manager.
in
QueueManager at line 452
QueueManager
setApplication(Container $app)
Set the application instance used by the manager.
Tests only. Swaps the container reference on the singleton and on every cached queue connection; per-request use races across coroutines and breaks every concurrent dispatch.
at line 798
__call(string $method, array $parameters)
Override the QueueManager to prevent circular dependency.
in
ReflectsClosures at line 25
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
in
ReflectsClosures at line 48
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
in
ReflectsClosures at line 74
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
in
ReflectsClosures at line 94
protected array
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
at line 109
QueueFake
except(array|string $jobsToBeQueued)
Specify the jobs that should be queued instead of faked.
at line 119
void
assertPushed(Closure|string $job, callable|int|null $callback = null)
Assert if a job was pushed based on a truth-test callback.
at line 139
void
assertPushedTimes(string $job, int $times = 1)
Assert if a job was pushed a number of times.
at line 157
void
assertPushedOnce(string $job)
Assert if a job was pushed exactly once.
at line 165
void
assertPushedOn(UnitEnum|string|null $queue, Closure|string $job, callable|null $callback = null)
Assert if a job was pushed based on a truth-test callback.
at line 188
void
assertPushedWithChain(string $job, array $expectedChain = [], callable|null $callback = null)
Assert if a job was pushed with chained jobs based on a truth-test callback.
at line 208
void
assertPushedWithoutChain(string $job, callable|null $callback = null)
Assert if a job was pushed with an empty chain based on a truth-test callback.
at line 221
protected void
assertPushedWithChainOfObjects(string $job, array $expectedChain, callable|null $callback)
Assert if a job was pushed with chained jobs based on a truth-test callback.
at line 234
protected void
assertPushedWithChainOfClasses(string $job, array $expectedChain, callable|null $callback)
Assert if a job was pushed with chained jobs based on a truth-test callback.
at line 253
void
assertClosurePushed(callable|int|null $callback = null)
Assert if a closure was pushed based on a truth-test callback.
at line 261
void
assertClosureNotPushed(callable|null $callback = null)
Assert that a closure was not pushed based on a truth-test callback.
at line 269
protected bool
isChainOfObjects(array $chain)
Determine if the given chain is entirely composed of objects.
at line 277
void
assertNotPushed(Closure|string $job, callable|null $callback = null)
Determine if a job was pushed based on a truth-test callback.
at line 293
void
assertCount(int $expectedCount)
Assert the total count of jobs that were pushed.
at line 307
void
assertNothingPushed()
Assert that no jobs were pushed.
at line 317
Collection
pushed(string $job, callable|null $callback = null)
Get all of the jobs matching a truth-test callback.
at line 336
Collection
pushedRaw(Closure|null $callback = null)
Get all of the raw pushes matching a truth-test callback.
at line 348
Collection
listenersPushed(string $listenerClass, callable|null $callback = null)
Get all of the jobs by listener class, passing an optional truth-test callback.
at line 369
bool
hasPushed(string $job)
Determine if there are any stored jobs for a given class.
at line 385
int
size(string|null $queue = null)
Get the size of the queue.
at line 395
int
pendingSize(string|null $queue = null)
Get the number of pending jobs.
at line 403
int
delayedSize(string|null $queue = null)
Get the number of delayed jobs.
at line 411
int
reservedSize(string|null $queue = null)
Get the number of reserved jobs.
at line 419
Collection
pendingJobs(UnitEnum|string|null $queue = null)
Get the pending jobs for the given queue.
at line 429
Collection
delayedJobs(UnitEnum|string|null $queue = null)
Get the delayed jobs for the given queue.
at line 439
Collection
reservedJobs(UnitEnum|string|null $queue = null)
Get the reserved jobs for the given queue.
at line 449
Collection
allPendingJobs()
Get all pending jobs across every queue.
at line 457
Collection
allDelayedJobs()
Get all delayed jobs across every queue.
at line 465
Collection
allReservedJobs()
Get all reserved jobs across every queue.
at line 473
protected Collection
inspectJobs(array $jobs)
Map an array of jobs to a collection of inspected jobs.
at line 492
protected array
pushedJobsWithDelay(bool $delayed)
Get pushed jobs classified by their delay.
at line 506
int|null
creationTimeOfOldestPendingJob(string|null $queue = null)
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
at line 517
mixed
push(object|string $job, mixed $data = '', string|null $queue = null)
Push a new job onto the queue.
at line 525
protected mixed
enqueueUsing(object|string $job, mixed $data, UnitEnum|string|null $queue, DateInterval|DateTimeInterface|int|null $delay)
Push a job through the fake or its underlying queue.
at line 576
bool
shouldFakeJob(object|string $job)
Determine if a job should be faked or actually dispatched.
at line 594
protected bool
shouldDispatchJob(object|string $job)
Determine if a job should be pushed to the queue instead of faked.
at line 608
mixed
pushRaw(string $payload, string|null $queue = null, array $options = [])
Push a raw payload onto the queue.
at line 622
mixed
later(DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '', string|null $queue = null)
Push a new job onto the queue after (n) seconds.
at line 634
mixed
pushOn(string|null $queue, object|string $job, mixed $data = '')
Push a new job onto the queue.
at line 642
mixed
laterOn(string|null $queue, DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '')
Push a new job onto a specific queue after (n) seconds.
at line 654
void
reserve(object|string $job, UnitEnum|string|null $queue = null)
Record the given job as reserved.
at line 672
Job|null
pop(string|null $queue = null)
Pop the next job off of the queue.
at line 680
mixed
bulk(array $jobs, mixed $data = '', string|null $queue = null)
Push an array of jobs onto the queue.
at line 694
array
pushedJobs()
Get the jobs that have been pushed.
at line 704
array
rawPushes()
Get the payloads that were pushed raw.
at line 712
QueueFake
serializeAndRestore(bool $serializeAndRestore = true)
Specify if jobs should be serialized and restored when being "pushed" to the queue.
at line 722
protected mixed
serializeAndRestoreJob(mixed $job)
Serialize and unserialize the job to simulate the queueing process.
at line 730
void
releaseUniqueJobLocks()
Release the locks for all unique jobs that were pushed.
at line 744
void
clearReserved()
Clear all of the reserved jobs.
at line 752
QueueFake
beforePushing(callable $callback)
Register a callback to be invoked before pushing a job.
at line 762
QueueFake
afterPushing(callable $callback)
Register a callback to be invoked after pushing a job.
at line 772
protected string|null
normalizeQueue(UnitEnum|string|null $queue)
Normalize a queue identifier.
at line 780
string
getConnectionName()
Get the connection name for the queue.
at line 788
Queue
setConnectionName(string $name)
Set the connection name for the queue.