Skip to content

[9.x] Add mailable assertions#44563

Merged
taylorotwell merged 4 commits into
laravel:9.xfrom
macbookandrew:feature/mail-assertions
Oct 12, 2022
Merged

[9.x] Add mailable assertions#44563
taylorotwell merged 4 commits into
laravel:9.xfrom
macbookandrew:feature/mail-assertions

Conversation

@macbookandrew

Copy link
Copy Markdown
Contributor

Currently, the Mailable class has a number of methods to determine whether the mailable has the given recipient, cc, bcc, attachments, etc.

The mailable includes a couple of direct assertions for attachments ($mail->assertHasAttachment(), etc.), but not for recipients, tags, or metadata.

This PR introduces the missing assertions:

Before:

$mailable = (new Mail())->build();

$this->assertTrue($mailable->hasTo('taylor@otwell.com'));
$this->assertTrue($mailable->hasCc('taylor@otwell.com'));
$this->assertTrue($mailable->hasBcc('taylor@otwell.com'));
$this->assertTrue($mailable->hasReplyTo('taylor@otwell.com'));
$this->assertTrue($mailable->hasReplyTo('taylor@otwell.com'));
$this->assertTrue($mailable->hasFrom('taylor@otwell.com'));
$this->assertTrue($mailable->hasTag('test'));
$this->assertTrue($mailable->hasMetadata('foo', 'bar'));

After:

$mailable = (new Mail())->build();

$mailable
	->assertHasTo('taylor@otwell.com')
	->assertHasCc('taylor@otwell.com')
	->assertHasBcc('taylor@otwell.com')
	->assertHasReplyTo('taylor@otwell.com')
	->assertHasReplyTo('taylor@otwell.com')
	->assertHasFrom('taylor@otwell.com')
	->assertHasTag('test')
	->assertHasMetadata('foo', 'bar');

@taylorotwell
taylorotwell merged commit 4bc8737 into laravel:9.x Oct 12, 2022
@GrahamCampbell GrahamCampbell changed the title add mailable assertions [9.x] Add mailable assertions Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants