Replies: 1 comment
-
@calebdw I'm finding that I'm agreeing with your perspective here, using I used the following code to remove the event listeners I wasn't interested in testing, can anyone explain why this might be a bad idea or perhaps the approach is ok?
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Laravel Version
9.52.x
PHP Version
8.1.x
Database Driver & Version
Postgres 14
Description
Hello!
It is very non-trivial to test Listeners with QueueFake at the moment; mostly because the Listeners are inside the
CallQueuedListener
job.Therefore, asserting whether or not a Listener was pushed requires something like:
which either requires duplicated code or a custom function (which is not ideal).
The issue I'm running into at the moment is that I have several Listeners listening to a specific Event, and I want to fake all but one of them (the one I'm currently testing). However, doing the following does not work:
as everything is faked because
<listener>
is not an actual job---I'm not sure if it's possible to actually fake a listener without overridingQueueFake::shouldDispatchJob()
.All in all, it would be very helpful to include first class testing support for Listeners just like with Jobs.
Thanks!
Steps To Reproduce
n/a
Beta Was this translation helpful? Give feedback.
All reactions