How to assert mail subject and from in test (Laravel v7.8.1)
I fail to assert from and subject in my tests in latest Laravel 7.8.1
use App\Mail\ContactUserMail;
…
public function testExample()
{
Mail::fake();
$this->get('/');
Mail::assertSent(ContactUserMail::class, function ($mail) {
dd($mail->subject, $mail->from);
});
}
// ContactUserMail
…
public function build()
{
return $this->from('[email protected]')->subject('A busy content')->markdown('emails.contactUserMail');
}
// web.php
Route::get('/', function () {
Mail::to('[email protected]')->send(new ContactUserMail);
});
This returns null, if I dd() the whole $mail, I only see the to, no from, subject either.