Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit bd66936

Browse files
committed
Merge pull request #20 from spinen/feature/addEmailDoesNotContain
Feature/add email does not contain
2 parents 6aa7b3b + 9805743 commit bd66936

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ You mixin the assertions with the ```Spinen\MailAssertions\MailTracking``` trait
3232
* seeEmailBcc
3333
* seeEmailCc
3434
* seeEmailContains
35+
* seeEmailDoesNotContain
3536
* seeEmailEquals
3637
* seeEmailFrom
3738
* seeEmailReplyTo

src/MailTracking.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ protected function seeEmailContains($excerpt, Swift_Message $message = null)
134134
return $this;
135135
}
136136

137+
/**
138+
* Assert that the last email's body does not contain the given text.
139+
*
140+
* @param string $excerpt
141+
* @param Swift_Message|null $message
142+
*
143+
* @return PHPUnit_Framework_TestCase $this
144+
*/
145+
protected function seeEmailDoesNotContain($excerpt, Swift_Message $message = null)
146+
{
147+
$this->assertNotContains($excerpt, $this->getEmail($message)
148+
->getBody(), "Email containing the provided text was found in the body.");
149+
150+
return $this;
151+
}
152+
137153
/**
138154
* Assert that the last email's body equals the given text.
139155
*

tests/MailTrackingTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ public function it_checks_email_body_for_content()
168168
$this->assertEquals($this->mail_tracking, $this->callProtectedMethod('seeEmailContains', ['body']));
169169
}
170170

171+
/**
172+
* @test
173+
* @group unit
174+
*/
175+
public function it_checks_email_body_does_not_have_content()
176+
{
177+
$message = $this->makeMessage('subject', '');
178+
$this->mail_tracking->recordMail($message);
179+
180+
$this->assertEquals($this->mail_tracking, $this->callProtectedMethod('seeEmailDoesNotContain', ['body']));
181+
}
182+
171183
/**
172184
* @test
173185
* @group unit

0 commit comments

Comments
 (0)