kfirba's avatar
Level 50

Test event listener class

Hello.

In my application I've created a MailListener which simply is the class which is responsible to send any kind of email based on which event has been triggered.

Currently there are 2 methods in that class which responds to different events:

  • confirmationEmail - responds to UserRegistered
  • businessRegistered - responds to BusinessHasRegistered

Now in my test I verify that an event has been indeed fired but I want to ensure that the right listener method has also been called.

I want to fire the UserRegistered event and make sure that a confirmationEmail method is being called with the UserRegistered event passed to it, that's all.

I'm not sure if it matters but that MailListener is queued but in my testing environment the queue is sync so it fires immediately.

0 likes
2 replies

Please or to participate in this conversation.