QueueFake
class QueueFake extends QueueManager implements Fake, Queue (View source)
Traits
Properties
| protected Application | $app | The application instance. |
from QueueManager |
| protected array | $connections | The array of resolved queue connections. |
from QueueManager |
| protected array | $connectors | The array of resolved queue connectors. |
from QueueManager |
| Queue | $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
Get the number of seconds until the given DateTime.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
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 a callback to be invoked when a job runs for longer than a given amount of time.
Set the queue route for the given class.
Forward the given queue to another queue and/or connection.
Determine if the driver is connected.
Resolve a queue connection instance.
Get the connector for a given driver.
Pause a queue by its name and connection.
Pause a queue by its name and connection for a given amount of time.
Resume a paused queue by its connection and name.
Determine if a queue is paused.
Determine which of the given queues are currently paused.
Indicate that queue workers should not poll for restart or pause signals.
Set the name of the default queue connection.
Get the full name for the given connection.
Register a callback to be executed when creating job payloads.
Override the QueueManager to prevent circular dependency.
No description
Get a configuration value from an attribute, falling back to a property.
Extract the value from an attribute instance.
Get an instance of the given attribute class from the target class or its parents.
Determine if a property declared on a child class overrides an inherited attribute.
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 raw pushes 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 number of jobs across every queue.
Get the number of pending jobs across every queue.
Get the number of delayed jobs across every queue.
Get the number of reserved jobs across every queue.
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.
Map an array of jobs to a collection of inspected jobs.
Get all reserved jobs across every queue.
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
Push a new job onto the queue.
Push a new job onto the fake 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.
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.
Get the connection name for the queue.
Set the connection name for the queue.
Details
protected int
secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime.
protected int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp.
protected DateTimeInterface|int
parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance.
protected int
currentTime()
Get the current system time as a UNIX timestamp.
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
string|null
resolveConnectionFromQueueRoute(object $queueable)
Resolve the default connection name for a given queueable instance.
string|null
resolveQueueFromQueueRoute(object $queueable)
Resolve the default queue name for a given queueable instance.
protected QueueRoutes
queueRoutes()
Get the queue routes manager instance.
__construct(Application $app, array $jobsToFake = [], QueueManager|null $queue = null)
Create a new fake queue instance.
void
before(mixed $callback)
Register an event listener for the before job event.
void
after(mixed $callback)
Register an event listener for the after job event.
void
exceptionOccurred(mixed $callback)
Register an event listener for the exception occurred job event.
void
looping(mixed $callback)
Register an event listener for the daemon queue loop.
void
failing(mixed $callback)
Register an event listener for the failed job event.
void
starting(mixed $callback)
Register an event listener for the daemon queue starting.
void
stopping(mixed $callback)
Register an event listener for the daemon queue stopping.
void
whenJobRunsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)
Register a callback to be invoked when a job runs for longer than a given amount of time.
void
route(array|string $class, UnitEnum|string|null $queue = null, UnitEnum|string|null $connection = null)
Set the queue route for the given class.
void
forward(array|string|UnitEnum $queue, UnitEnum|string|null $to = null, UnitEnum|string|null $connection = null)
Forward the given queue to another queue and/or connection.
bool
connected(UnitEnum|string|null $name = null)
Determine if the driver is connected.
Queue
connection(mixed $value = null)
Resolve a queue connection instance.
protected Queue
resolve(string $name)
Resolve a queue connection.
protected ConnectorInterface
getConnector(string $driver)
Get the connector for a given driver.
void
pause(UnitEnum|string $queue, UnitEnum|string|null $connection = null)
Pause a queue by its name and connection.
void
pauseFor(UnitEnum|string $queue, DateTimeInterface|DateInterval|int $ttl, UnitEnum|string|null $connection = null)
Pause a queue by its name and connection for a given amount of time.
void
pauseAll()
Pause job processing for all queues on all connections.
void
resume(UnitEnum|string $queue, UnitEnum|string|null $connection = null)
Resume a paused queue by its connection and name.
void
resumeAll()
Resume job processing for all queues on all connections.
Queues paused individually are not affected.
bool
isPaused(UnitEnum|string $queue, UnitEnum|string|null $connection = null)
Determine if a queue is paused.
array
getPausedQueues(array $queues, string|null $connection = null)
Determine which of the given queues are currently paused.
void
withoutInterruptionPolling()
Indicate that queue workers should not poll for restart or pause signals.
This prevents the workers from hitting the application cache to determine if they need to pause or restart.
void
extend(string $driver, Closure $resolver)
Add a queue connection resolver.
void
addConnector(string $driver, Closure $resolver)
Add a queue connection resolver.
protected array|null
getConfig(string $name)
Get the queue connection configuration.
string
getDefaultDriver()
Get the name of the default queue connection.
void
setDefaultDriver(UnitEnum|string $name)
Set the name of the default queue connection.
string
getName(string|null $connection = null)
Get the full name for the given connection.
Application
getApplication()
Get the application instance used by the manager.
$this
setApplication(Application $app)
Set the application instance used by the manager.
void
createPayloadUsing(callable|null $callback)
Register a callback to be executed when creating job payloads.
mixed
__call(string $method, array $parameters)
Override the QueueManager to prevent circular dependency.
protected callable|null
resolveTruthTest(callable|array<string, mixed>|null $callback)
No description
protected mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)
Get a configuration value from an attribute, falling back to a property.
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
protected object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)
Get an instance of the given attribute class from the target class or its parents.
protected bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)
Determine if a property declared on a child class overrides an inherited attribute.
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
protected list<class-string>
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
$this
except(array|string $jobsToBeQueued)
Specify the jobs that should be queued instead of faked.
void
assertPushed(string|Closure $job, callable|array<string, mixed>|int|null $callback = null)
Assert if a job was pushed based on a truth-test callback.
void
assertPushedTimes(string $job, int $times = 1)
Assert if a job was pushed a number of times.
void
assertPushedOnce(string $job)
Assert if a job was pushed exactly once.
void
assertPushedOn(UnitEnum|string $queue, string|Closure $job, callable|array<string, mixed>|null $callback = null)
Assert if a job was pushed based on a truth-test callback.
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.
void
assertPushedWithoutChain(string $job, callable|null $callback = null)
Assert if a job was pushed with an empty chain based on a truth-test callback.
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.
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.
void
assertClosurePushed(callable|int|null $callback = null)
Assert if a closure was pushed based on a truth-test callback.
void
assertClosureNotPushed(callable|null $callback = null)
Assert that a closure was not pushed based on a truth-test callback.
protected bool
isChainOfObjects(array $chain)
Determine if the given chain is entirely composed of objects.
void
assertNotPushed(string|Closure $job, callable|array<string, mixed>|null $callback = null)
Determine if a job was pushed based on a truth-test callback.
void
assertCount(int $expectedCount)
Assert the total count of jobs that were pushed.
void
assertNothingPushed()
Assert that no jobs were pushed.
Collection
pushed(string $job, callable|array<string, mixed>|null $callback = null)
Get all of the jobs matching a truth-test callback.
RawPushType>
pushedRaw(null|Closure(string, ?string, array): bool $callback = null)
Get all of the raw pushes matching a truth-test callback.
CallQueuedListener>
listenersPushed(class-string $listenerClass, CallQueuedListener, string|null, mixed): bool|null $callback = null)
Get all of the jobs by listener class, passing an optional truth-test callback.
bool
hasPushed(string $job)
Determine if there are any stored jobs for a given class.
int
size(UnitEnum|string|null $queue = null)
Get the size of the queue.
int
pendingSize(UnitEnum|string|null $queue = null)
Get the number of pending jobs.
int
delayedSize(UnitEnum|string|null $queue = null)
Get the number of delayed jobs.
int
reservedSize(UnitEnum|string|null $queue = null)
Get the number of reserved jobs.
int
totalSize()
Get the number of jobs across every queue.
int
totalPendingSize()
Get the number of pending jobs across every queue.
int
totalDelayedSize()
Get the number of delayed jobs across every queue.
int
totalReservedSize()
Get the number of reserved jobs across every queue.
InspectedJob>
pendingJobs(UnitEnum|string|null $queue = null)
Get the pending jobs for the given queue.
InspectedJob>
delayedJobs(UnitEnum|string|null $queue = null)
Get the delayed jobs for the given queue.
InspectedJob>
reservedJobs(UnitEnum|string|null $queue = null)
Get the reserved jobs for the given queue.
InspectedJob>
allPendingJobs()
Get all pending jobs across every queue.
InspectedJob>
allDelayedJobs()
Get all delayed jobs across every queue.
protected Collection
inspectJobs(array $jobs, bool|null $delayed = null)
Map an array of jobs to a collection of inspected jobs.
InspectedJob>
allReservedJobs()
Get all reserved jobs across every queue.
int|null
creationTimeOfOldestPendingJob(UnitEnum|string|null $queue = null)
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
mixed
push(string|object $job, mixed $data = '', UnitEnum|string|null $queue = null)
Push a new job onto the queue.
protected void
pushJob(string|object $job, mixed $data = '', UnitEnum|string|null $queue = null, bool $delayed = false)
Push a new job onto the fake queue.
bool
shouldFakeJob(object $job)
Determine if a job should be faked or actually dispatched.
protected bool
shouldDispatchJob(object $job)
Determine if a job should be pushed to the queue instead of faked.
mixed
pushRaw(string $payload, UnitEnum|string|null $queue = null, array $options = [])
Push a raw payload onto the queue.
mixed
later(DateTimeInterface|DateInterval|int $delay, string|object $job, mixed $data = '', UnitEnum|string|null $queue = null)
Push a new job onto the queue after (n) seconds.
mixed
pushOn(UnitEnum|string $queue, string|object $job, mixed $data = '')
Push a new job onto the queue.
mixed
laterOn(UnitEnum|string $queue, DateTimeInterface|DateInterval|int $delay, string|object $job, mixed $data = '')
Push a new job onto a specific queue after (n) seconds.
void
reserve(Closure|string|object $job, UnitEnum|string|null $queue = null)
Mark the given job as reserved.
Job|null
pop(UnitEnum|string|null $queue = null)
Pop the next job off of the queue.
mixed
bulk(array $jobs, mixed $data = '', UnitEnum|string|null $queue = null)
Push an array of jobs onto the queue.
array
pushedJobs()
Get the jobs that have been pushed.
RawPushType>
rawPushes()
Get the payloads that were pushed raw.
$this
serializeAndRestore(bool $serializeAndRestore = true)
Specify if jobs should be serialized and restored when being "pushed" to the queue.
protected mixed
serializeAndRestoreJob(mixed $job)
Serialize and unserialize the job to simulate the queueing process.
void
releaseUniqueJobLocks()
Release the locks for all unique jobs that were pushed.
void
clearReserved()
Clear all of the reserved jobs.
$this
beforePushing(callable $callback)
Register a callback to be invoked before pushing a job.
$this
afterPushing(callable $callback)
Register a callback to be invoked after pushing a job.
string
getConnectionName()
Get the connection name for the queue.
$this
setConnectionName(string $name)
Set the connection name for the queue.