RonasIT / laravel-helpers

11 stars 14 forks source link

The message variable missing error in testing Mails #136

Open DenTray opened 2 months ago

DenTray commented 2 months ago

According to the Laravel doc https://laravel.com/docs/5.8/mail#inline-attachments Laravel automatically add the message variable inside the template.

But while testing it, phpunit will fail with the next error

image image

In fact it works fine for the real email send

image
DenTray commented 2 months ago

The main reason of this one is merging the message variable into the view data on the sending level instead of preparing mail object

https://github.com/laravel/framework/blob/c2eb31872aa092cdd4ae977886636b76b1064bd8/src/Illuminate/Mail/Mailer.php#L311

As a first step to resolve this one - we need to try to get the mail content from the log driver instead of mocking Mail