Testing Queued Listeners
When we fire an event, a listener possibly handles quite much work behind the scenes, so often we queue them. Laravel offers this by default, all we need to do to implement the ShouldQueue contract and pull in the InteractsWithQueue trait. The rest is up to Laravel.
But when it comes to testing, things are a bit more tricky. According to the documentation, it’s easy to test our queued jobs. But what about the listeners? Using this snippet, we can test if the listener is pushed to the queue or not:
Follow us on Twitter
Do you want to support and help us? A Twitter following or a sharing means a lot to us. Thank you!