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 bool $serializeAndRestore

Indicates if items should be serialized and restored when pushed to the queue.

Methods

__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.

bool
connected(string|null $name = null)

Determine if the driver is connected.

connection(mixed $value = null)

Resolve a queue connection instance.

resolve(string $name)

Resolve a queue connection.

getConnector(string $driver)

Get the connector for a given driver.

void
pause(string $connection, string $queue)

Pause a queue by its connection and name.

void
pauseFor(string $connection, string $queue, DateTimeInterface|DateInterval|int $ttl)

Pause a queue by its connection and name for a given amount of time.

void
resume(string $connection, string $queue)

Resume a paused queue by its connection and name.

bool
isPaused(string $connection, string $queue)

Determine if a queue is paused.

void
withoutInterruptionPolling()

Indicate that queue workers should not poll for restart or pause signals.

void
extend(string $driver, Closure $resolver)

Add a queue connection resolver.

void
addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

array|null
getConfig(string $name)

Get the queue connection configuration.

string
getDefaultDriver()

Get the name of the default queue connection.

void
setDefaultDriver(string $name)

Set the name of the default queue connection.

string
getName(string|null $connection = null)

Get the full name for the given connection.

getApplication()

Get the application instance used by the manager.

$this
setApplication(Application $app)

Set the application instance used by the manager.

mixed
__call(string $method, array $parameters)

Override the QueueManager to prevent circular dependency.

string
firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

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|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
assertPushedOn(string $queue, string|Closure $job, callable|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.

void
assertPushedWithChainOfObjects(string $job, array $expectedChain, callable|null $callback)

Assert if a job was pushed with chained jobs based on a truth-test callback.

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.

bool
isChainOfObjects(array $chain)

Determine if the given chain is entirely composed of objects.

void
assertNotPushed(string|Closure $job, callable|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.

pushed(string $job, callable|null $callback = null)

Get all of the jobs matching a truth-test callback.

RawPushType>
pushedRaw($callback = null)

Get all of the raw pushes matching a truth-test callback.

CallQueuedListener>
listenersPushed(class-string $listenerClass, $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(string|null $queue = null)

Get the size of the queue.

int
pendingSize(string|null $queue = null)

Get the number of pending jobs.

int
delayedSize(string|null $queue = null)

Get the number of delayed jobs.

int
reservedSize(string|null $queue = null)

Get the number of reserved jobs.

int|null
creationTimeOfOldestPendingJob(string|null $queue = null)

Get the creation timestamp of the oldest pending job, excluding delayed jobs.

mixed
push(string|object $job, mixed $data = '', string|null $queue = null)

Push a new job onto the queue.

bool
shouldFakeJob(object $job)

Determine if a job should be faked or actually dispatched.

bool
shouldDispatchJob(object $job)

Determine if a job should be pushed to the queue instead of faked.

mixed
pushRaw(string $payload, string|null $queue = null, array $options = [])

Push a raw payload onto the queue.

mixed
later(DateTimeInterface|DateInterval|int $delay, string|object $job, mixed $data = '', string|null $queue = null)

Push a new job onto the queue after (n) seconds.

mixed
pushOn(string $queue, string|object $job, mixed $data = '')

Push a new job onto the queue.

mixed
laterOn(string $queue, DateTimeInterface|DateInterval|int $delay, string|object $job, mixed $data = '')

Push a new job onto a specific queue after (n) seconds.

Job|null
pop(string|null $queue = null)

Pop the next job off of the queue.

mixed
bulk(array $jobs, mixed $data = '', 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.

mixed
serializeAndRestoreJob(mixed $job)

Serialize and unserialize the job to simulate the queueing process.

string
getConnectionName()

Get the connection name for the queue.

$this
setConnectionName(string $name)

Set the connection name for the queue.

Details

__construct(Application $app, array $jobsToFake = [], QueueManager|null $queue = null)

Create a new fake queue instance.

Parameters

Application $app
array $jobsToFake
QueueManager|null $queue

void before(mixed $callback)

Register an event listener for the before job event.

Parameters

mixed $callback

Return Value

void

void after(mixed $callback)

Register an event listener for the after job event.

Parameters

mixed $callback

Return Value

void

void exceptionOccurred(mixed $callback)

Register an event listener for the exception occurred job event.

Parameters

mixed $callback

Return Value

void

void looping(mixed $callback)

Register an event listener for the daemon queue loop.

Parameters

mixed $callback

Return Value

void

void failing(mixed $callback)

Register an event listener for the failed job event.

Parameters

mixed $callback

Return Value

void

void starting(mixed $callback)

Register an event listener for the daemon queue starting.

Parameters

mixed $callback

Return Value

void

void stopping(mixed $callback)

Register an event listener for the daemon queue stopping.

Parameters

mixed $callback

Return Value

void

bool connected(string|null $name = null)

Determine if the driver is connected.

Parameters

string|null $name

Return Value

bool

Queue connection(mixed $value = null)

Resolve a queue connection instance.

Parameters

mixed $value

Return Value

Queue

protected Queue resolve(string $name)

Resolve a queue connection.

Parameters

string $name

Return Value

Queue

Exceptions

InvalidArgumentException

protected ConnectorInterface getConnector(string $driver)

Get the connector for a given driver.

Parameters

string $driver

Return Value

ConnectorInterface

Exceptions

InvalidArgumentException

void pause(string $connection, string $queue)

Pause a queue by its connection and name.

Parameters

string $connection
string $queue

Return Value

void

void pauseFor(string $connection, string $queue, DateTimeInterface|DateInterval|int $ttl)

Pause a queue by its connection and name for a given amount of time.

Parameters

string $connection
string $queue
DateTimeInterface|DateInterval|int $ttl

Return Value

void

void resume(string $connection, string $queue)

Resume a paused queue by its connection and name.

Parameters

string $connection
string $queue

Return Value

void

bool isPaused(string $connection, string $queue)

Determine if a queue is paused.

Parameters

string $connection
string $queue

Return Value

bool

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.

Return Value

void

void extend(string $driver, Closure $resolver)

Add a queue connection resolver.

Parameters

string $driver
Closure $resolver

Return Value

void

void addConnector(string $driver, Closure $resolver)

Add a queue connection resolver.

Parameters

string $driver
Closure $resolver

Return Value

void

protected array|null getConfig(string $name)

Get the queue connection configuration.

Parameters

string $name

Return Value

array|null

string getDefaultDriver()

Get the name of the default queue connection.

Return Value

string

void setDefaultDriver(string $name)

Set the name of the default queue connection.

Parameters

string $name

Return Value

void

string getName(string|null $connection = null)

Get the full name for the given connection.

Parameters

string|null $connection

Return Value

string

Application getApplication()

Get the application instance used by the manager.

Return Value

Application

$this setApplication(Application $app)

Set the application instance used by the manager.

Parameters

Application $app

Return Value

$this

mixed __call(string $method, array $parameters)

Override the QueueManager to prevent circular dependency.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

protected array firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

protected list<class-string> closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

list<class-string>

Exceptions

ReflectionException

$this except(array|string $jobsToBeQueued)

Specify the jobs that should be queued instead of faked.

Parameters

array|string $jobsToBeQueued

Return Value

$this

void assertPushed(string|Closure $job, callable|int|null $callback = null)

Assert if a job was pushed based on a truth-test callback.

Parameters

string|Closure $job
callable|int|null $callback

Return Value

void

protected void assertPushedTimes(string $job, int $times = 1)

Assert if a job was pushed a number of times.

Parameters

string $job
int $times

Return Value

void

void assertPushedOn(string $queue, string|Closure $job, callable|null $callback = null)

Assert if a job was pushed based on a truth-test callback.

Parameters

string $queue
string|Closure $job
callable|null $callback

Return Value

void

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.

Parameters

string $job
array $expectedChain
callable|null $callback

Return Value

void

void assertPushedWithoutChain(string $job, callable|null $callback = null)

Assert if a job was pushed with an empty chain based on a truth-test callback.

Parameters

string $job
callable|null $callback

Return Value

void

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.

Parameters

string $job
array $expectedChain
callable|null $callback

Return Value

void

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.

Parameters

string $job
array $expectedChain
callable|null $callback

Return Value

void

void assertClosurePushed(callable|int|null $callback = null)

Assert if a closure was pushed based on a truth-test callback.

Parameters

callable|int|null $callback

Return Value

void

void assertClosureNotPushed(callable|null $callback = null)

Assert that a closure was not pushed based on a truth-test callback.

Parameters

callable|null $callback

Return Value

void

protected bool isChainOfObjects(array $chain)

Determine if the given chain is entirely composed of objects.

Parameters

array $chain

Return Value

bool

void assertNotPushed(string|Closure $job, callable|null $callback = null)

Determine if a job was pushed based on a truth-test callback.

Parameters

string|Closure $job
callable|null $callback

Return Value

void

void assertCount(int $expectedCount)

Assert the total count of jobs that were pushed.

Parameters

int $expectedCount

Return Value

void

void assertNothingPushed()

Assert that no jobs were pushed.

Return Value

void

Collection pushed(string $job, callable|null $callback = null)

Get all of the jobs matching a truth-test callback.

Parameters

string $job
callable|null $callback

Return Value

Collection

RawPushType> pushedRaw($callback = null)

Get all of the raw pushes matching a truth-test callback.

Parameters

$callback

Return Value

RawPushType>

CallQueuedListener> listenersPushed(class-string $listenerClass, $callback = null)

Get all of the jobs by listener class, passing an optional truth-test callback.

Parameters

class-string $listenerClass
$callback

Return Value

CallQueuedListener>

bool hasPushed(string $job)

Determine if there are any stored jobs for a given class.

Parameters

string $job

Return Value

bool

int size(string|null $queue = null)

Get the size of the queue.

Parameters

string|null $queue

Return Value

int

int pendingSize(string|null $queue = null)

Get the number of pending jobs.

Parameters

string|null $queue

Return Value

int

int delayedSize(string|null $queue = null)

Get the number of delayed jobs.

Parameters

string|null $queue

Return Value

int

int reservedSize(string|null $queue = null)

Get the number of reserved jobs.

Parameters

string|null $queue

Return Value

int

int|null creationTimeOfOldestPendingJob(string|null $queue = null)

Get the creation timestamp of the oldest pending job, excluding delayed jobs.

Parameters

string|null $queue

Return Value

int|null

mixed push(string|object $job, mixed $data = '', string|null $queue = null)

Push a new job onto the queue.

Parameters

string|object $job
mixed $data
string|null $queue

Return Value

mixed

bool shouldFakeJob(object $job)

Determine if a job should be faked or actually dispatched.

Parameters

object $job

Return Value

bool

protected bool shouldDispatchJob(object $job)

Determine if a job should be pushed to the queue instead of faked.

Parameters

object $job

Return Value

bool

mixed pushRaw(string $payload, string|null $queue = null, array $options = [])

Push a raw payload onto the queue.

Parameters

string $payload
string|null $queue
array $options

Return Value

mixed

mixed later(DateTimeInterface|DateInterval|int $delay, string|object $job, mixed $data = '', string|null $queue = null)

Push a new job onto the queue after (n) seconds.

Parameters

DateTimeInterface|DateInterval|int $delay
string|object $job
mixed $data
string|null $queue

Return Value

mixed

mixed pushOn(string $queue, string|object $job, mixed $data = '')

Push a new job onto the queue.

Parameters

string $queue
string|object $job
mixed $data

Return Value

mixed

mixed laterOn(string $queue, DateTimeInterface|DateInterval|int $delay, string|object $job, mixed $data = '')

Push a new job onto a specific queue after (n) seconds.

Parameters

string $queue
DateTimeInterface|DateInterval|int $delay
string|object $job
mixed $data

Return Value

mixed

Job|null pop(string|null $queue = null)

Pop the next job off of the queue.

Parameters

string|null $queue

Return Value

Job|null

mixed bulk(array $jobs, mixed $data = '', string|null $queue = null)

Push an array of jobs onto the queue.

Parameters

array $jobs
mixed $data
string|null $queue

Return Value

mixed

array pushedJobs()

Get the jobs that have been pushed.

Return Value

array

RawPushType> rawPushes()

Get the payloads that were pushed raw.

Return Value

RawPushType>

$this serializeAndRestore(bool $serializeAndRestore = true)

Specify if jobs should be serialized and restored when being "pushed" to the queue.

Parameters

bool $serializeAndRestore

Return Value

$this

protected mixed serializeAndRestoreJob(mixed $job)

Serialize and unserialize the job to simulate the queueing process.

Parameters

mixed $job

Return Value

mixed

string getConnectionName()

Get the connection name for the queue.

Return Value

string

$this setConnectionName(string $name)

Set the connection name for the queue.

Parameters

string $name

Return Value

$this