Blog & Stuff

Mocking Queue Service for faster Behat Testing

Posted: 2014-11-23 19:36:57

As I wrote about here I am using behat to tests our APIs. I could have used Laravel's guzzle and phpunit integration to test the controllers but I decided to go with Behat. But this means when hitting those endpoints I need to find another way to mock services.

Since Laravel has you register Providers you can easily replace or override a provider. In this case the "'Illuminate\Queue\QueueServiceProvider'" provider with my own.

This allows me to test in my endpoints leaving the queue related classes to be tested during phpunit testing. Using the queue "sync" driver would help too but it would then cause this to not be an isolated tests since the queue would trigger another classes method. (@fire).