Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add mailable assertions #44563

Merged
merged 4 commits into from
Oct 12, 2022

Conversation

macbookandrew
Copy link
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('[email protected]'));
$this->assertTrue($mailable->hasCc('[email protected]'));
$this->assertTrue($mailable->hasBcc('[email protected]'));
$this->assertTrue($mailable->hasReplyTo('[email protected]'));
$this->assertTrue($mailable->hasReplyTo('[email protected]'));
$this->assertTrue($mailable->hasFrom('[email protected]'));
$this->assertTrue($mailable->hasTag('test'));
$this->assertTrue($mailable->hasMetadata('foo', 'bar'));

After:

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

$mailable
	->assertHasTo('[email protected]')
	->assertHasCc('[email protected]')
	->assertHasBcc('[email protected]')
	->assertHasReplyTo('[email protected]')
	->assertHasReplyTo('[email protected]')
	->assertHasFrom('[email protected]')
	->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