You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to test multiple event listeners that listen for Laravel's built-in queue events (all the events that live in the Illuminate\Queue\Events namespace. The listeners are part of a package.
Normally, if I want to test the behaviour of an event listener, I would do something like this:
Create the event that the listener should handle.
Instantiate the event listener and call its handle method on the event.
Assert that the actions (in this example sending a notification) are executed properly.
publicfunctiontest_updates_status_to_queued_in_database(): void
{
$event = newJobQueued(...); // I have to manually specify the payload (don't want to do that)
}
I also tried just dispatching a job and running it but the JobQueued event never fires:
How do I properly create the JobQueued event, so I can test my listener?
For clarification, the setQueuedStatus() method on the updater class. Its purpose is to set the status to queued and attach the uuid, which we can then use to track it during processing.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I want to test multiple event listeners that listen for Laravel's built-in queue events (all the events that live in the
Illuminate\Queue\Events
namespace. The listeners are part of a package.Normally, if I want to test the behaviour of an event listener, I would do something like this:
handle
method on the event.My listener that listens to the
JobQueued
event:When I try to create the
JobQueued
event:I also tried just dispatching a job and running it but the
JobQueued
event never fires:How do I properly create the
JobQueued
event, so I can test my listener?For clarification, the
setQueuedStatus()
method on theupdater
class. Its purpose is to set the status to queued and attach the uuid, which we can then use to track it during processing.The
TrackedJob
class is a test job with an emptyhandle()
method.Beta Was this translation helpful? Give feedback.
All reactions