-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mail:fake()/Queue::fake() not working with Mail::queue() #15919
Comments
experiencing something similar with an existing package. |
PR submitted with a fix #16248 |
@themsaid I seem to be having the same problem with laravel/framework 5.3.25 which includes your PR On a clean Laravel install, I tracked it down to the following two statements and wrote this demo test:
I get:
Here is setQueue in Illuminate/Mail/Mailer:
Remove the typehint and it all seems to work:
|
Another solution is to add the interface to Illuminate\Support\Testing\Fakes\QueueFake:
|
for laravel 5.4 mail::queue works just fine but for lumen 5.4 it gives this error. Frustrating |
I am facing the issue with |
@themsaid I believe this is still an issue. I can open a new issue if needed with a test case. |
@VinceG if on 5.4 then yes go ahead and open an issue with more details please. thanks :) |
just a few months left to 2018 and this issue still open... 😞 |
See #20454. Looks like any remaining unsolved issues should be covered. If there's an issue in the current release of Laravel, submit an new issue. This one will not get any attention since it's closed, |
This might be too late for most people, but if you're still bound to Laravel 5.3 here's my solution. I was using Mailables implementing the It's just not suited for testing Mailables but with a few adjustments you can make it work. First after calling
Otherwise it would still use the QueueManager instead of QueueFake Then you have to assert whether
You would also have to override some functions in the Mailable class and include that instead of
You will also have to extend QueueFake and the Queue facade, because the system will whine that QueueFake doesn't implement
This doesn't give any problems because QueueFake implicitly already implements My Queue facade:
|
Description:
It seems that when using
Mail::fake()
in a test and the controller / method usesMail::queue()
it fails due to the queue function not being available on theMailFake
class.I have also tried
Queue::fake()
however Mailables do not use the correct interface to fake the queue.I do understand that mail going to a queue won't be treated normally as is. However if it may or may not send it to a queue based on conditional logic in the controller this can raise a fairly significant problem. Also due to
Queue::fake()
failing if you try to queue mail and send a normal job to a queue the job will fail.I tried to look into the source, but could not accurately grasp how it all works. Will probably continue to look through it though.
Steps To Reproduce:
Try to use
Mail::fake()
for a test with a controller using a Mailable inMail::queue()
.Use
Queue::fake()
instead ofMail::fake()
for the same as above.Controller
Test
The text was updated successfully, but these errors were encountered: