Skip to content

Commit 2fc3ac7

Browse files
Improve Testing Mailable Content section (#10617)
1 parent 14acbfa commit 2fc3ac7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mail.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,9 +1182,7 @@ Mail::to($request->user())->send(new OrderShipped($order));
11821182
<a name="testing-mailable-content"></a>
11831183
### Testing Mailable Content
11841184

1185-
Laravel provides a variety of methods for inspecting your mailable's structure. In addition, Laravel provides several convenient methods for testing that your mailable contains the content that you expect. These methods are: `assertSeeInHtml`, `assertDontSeeInHtml`, `assertSeeInOrderInHtml`, `assertSeeInText`, `assertDontSeeInText`, `assertSeeInOrderInText`, `assertHasAttachment`, `assertHasAttachedData`, `assertHasAttachmentFromStorage`, and `assertHasAttachmentFromStorageDisk`.
1186-
1187-
As you might expect, the "HTML" assertions assert that the HTML version of your mailable contains a given string, while the "text" assertions assert that the plain-text version of your mailable contains a given string:
1185+
Laravel provides a variety of methods for inspecting your mailable's structure. In addition, Laravel provides several convenient methods for testing that your mailable contains the content that you expect:
11881186

11891187
```php tab=Pest
11901188
use App\Mail\InvoicePaid;
@@ -1205,10 +1203,11 @@ test('mailable content', function () {
12051203
$mailable->assertHasMetadata('key', 'value');
12061204

12071205
$mailable->assertSeeInHtml($user->email);
1208-
$mailable->assertSeeInHtml('Invoice Paid');
1206+
$mailable->assertDontSeeInHtml('Invoice Not Paid');
12091207
$mailable->assertSeeInOrderInHtml(['Invoice Paid', 'Thanks']);
12101208

12111209
$mailable->assertSeeInText($user->email);
1210+
$mailable->assertDontSeeInText('Invoice Not Paid');
12121211
$mailable->assertSeeInOrderInText(['Invoice Paid', 'Thanks']);
12131212

12141213
$mailable->assertHasAttachment('/path/to/file');
@@ -1239,10 +1238,11 @@ public function test_mailable_content(): void
12391238
$mailable->assertHasMetadata('key', 'value');
12401239

12411240
$mailable->assertSeeInHtml($user->email);
1242-
$mailable->assertSeeInHtml('Invoice Paid');
1241+
$mailable->assertDontSeeInHtml('Invoice Not Paid');
12431242
$mailable->assertSeeInOrderInHtml(['Invoice Paid', 'Thanks']);
12441243

12451244
$mailable->assertSeeInText($user->email);
1245+
$mailable->assertDontSeeInText('Invoice Not Paid');
12461246
$mailable->assertSeeInOrderInText(['Invoice Paid', 'Thanks']);
12471247

12481248
$mailable->assertHasAttachment('/path/to/file');
@@ -1253,6 +1253,8 @@ public function test_mailable_content(): void
12531253
}
12541254
```
12551255

1256+
As you might expect, the "HTML" assertions assert that the HTML version of your mailable contains a given string, while the "text" assertions assert that the plain-text version of your mailable contains a given string.
1257+
12561258
<a name="testing-mailable-sending"></a>
12571259
### Testing Mailable Sending
12581260

0 commit comments

Comments
 (0)