Testing listeners in Laravel 5.1

Is there a standard way to unit test Listeners in Laravel 5.1 (without mocking Event::fire() ), or just create it, call handle() with the mocked parameters and make statements, the old way?

I read Events and Testing and in fact it says nothing about unit testing listeners.

+5
source share
1 answer

AFAIK it is entirely up to you and your preferences. You could do one of the two approaches mentioned, but I do not test them at all. Instead, I try to have only very simple code in the Listener and move all the logic into separate services. IMHO, which makes the code more understandable and clean to unit test without mocking it.

+1
source

All Articles