nothingworksinc / ticketbeast

Back to the lesson videos:
https://course.testdrivenlaravel.com/lessons
552 stars 11 forks source link

How to test the queueing mail ? #50

Closed guitarbien closed 7 years ago

guitarbien commented 7 years ago

Hi, everyone

I'm wondering if we use queue or job to handle a business logic, should we have to care about adding to the queue correctly and write the test for that, or we could use something like FakeQueue for testing is enough ?

What if we use Mail::queue() or Mail::later() to send a mail. Should mail::assertSent() work with that ?

Wish Adam will talk about queue / job implement and testing detail in the future.

Thanks.

tomschlick commented 7 years ago

I'm sure Adam will touch on it at some point but there is a Queue::fake() method that works similar to Mail::fake()

https://laravel.com/docs/5.4/mocking#queue-fake

guitarbien commented 7 years ago

wow thank you ! I didn't notice that, I'll give it a try.

LostKobrakai commented 7 years ago

I think it's like with Stripe. Test your queue implementation(s) with contract tests, and use a Fake implementation anywhere else.