Skip to content

Conversation

@jpeters8889
Copy link

I recently had an issue where some tests were failing that used the Mail::fake() and Mail::assert...() methods.

Rather than using the Mail facade or anything in the controller I was injecting Illuminate\Contracts\Mail\Mailerand then using that to send my emails. After a lot of debugging I found that when I was using dd() in the controller on the Mailer variable while running the failing test, it was actually an instance of the Helo Mailer rather than the MailFake I was expecting.

I fixed this by updating my phpunit.xml to set the HELO_ENABLED env variable to false. At first, it wasn't immediately obvious that Helo was causing the issue and that I could stop the Helo Mailer getting instantiated by adding the variable, which is why I created this PR just to update the Service Provider to return early if $this->app->runningUnitTests() is true for anyone else that runs into this issue and to save a couple of hours of trying to figure out why!

@mpociot mpociot merged commit 411c44e into beyondcode:master Nov 17, 2020
@mpociot
Copy link
Member

mpociot commented Nov 17, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants