docs icon indicating copy to clipboard operation
docs copied to clipboard

Updates Mail::pretend to Mail::fake and adds template-based testing example

Open Mrkbingham opened this issue 1 year ago • 1 comments

It appears this section of the docs is outdated. The Mail::pretend() method was a part of Laravel's Mail facade in versions prior to Laravel 5.5. This method was used to prevent emails from actually being sent during testing, and instead write them to the application's log files.

However, this method has been removed in Laravel 5.5 and later versions. The recommended way to prevent emails from being sent during testing is to use the Mail::fake() method, which is part of the Mail facade in Laravel 5.5 and later versions.

There is one example added here that is not very clear in the Laravel documentation since theirs only passes through classes, and checking for templates will be very relevant to WinterCMS developers.

Mrkbingham avatar Jan 23 '24 00:01 Mrkbingham

@Mrkbingham thanks for submitting this PR.

We still provide the pretend() method in our Mailer implementation for backwards compatibility, and it does serve a separate purpose to the fake Mail instances provided by the Mail::fake() facade method - dynamically recording mail in logs as opposed to allowing test assertions through the MailFake instance.

I would suggest that perhaps we display both in the docs and outline the scenarios in which you would use one or the other - ie. use pretend() for quick logging of mail during development, and use fake() for unit testing.

Any thoughts on this?

bennothommo avatar Jan 23 '24 06:01 bennothommo