-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example of Mail::fake() for unit testing in docs (#170)
- Loading branch information
1 parent
b368919
commit 49af870
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -465,3 +465,18 @@ You can dynamically disable sending mail using the `Mail::pretend` method. When | |
```php | ||
Mail::pretend(); | ||
``` | ||
|
||
### Unit testing | ||
|
||
When unit testing, you may want to utilize Laravel's `fake` method on the Mail facade. This ensures your local configuration is ignored and mailing assertions can be performed without sending emails while your tests are running: | ||
|
||
```php | ||
Mail::fake(); | ||
|
||
// ... Run code that sends email 'this.is.my.email' template. | ||
|
||
// Check that the email was sent | ||
Mail::assertSent('this.is.my.email', function ($mail) { | ||
return $mail->hasTo('[email protected]'); | ||
}); | ||
``` |