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

Commit d376cc5

Browse files
committed
Assertions for subject to work like body. Fixes #11
1 parent 1ef2e50 commit d376cc5

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/MailTracking.php

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ protected function seeEmailContains($excerpt, Swift_Message $message = null)
145145
protected function seeEmailDoesNotContain($excerpt, Swift_Message $message = null)
146146
{
147147
$this->assertNotContains($excerpt, $this->getEmail($message)
148-
->getBody(), "Email containing the provided text was found in the body.");
148+
->getBody(),
149+
"Email containing the provided text was found in the body.");
149150

150151
return $this;
151152
}
@@ -225,13 +226,45 @@ protected function seeEmailsSent($count)
225226
*/
226227
protected function seeEmailSubject($subject, Swift_Message $message = null)
227228
{
228-
// TODO: Consider a subject contains like the message contains
229229
$this->assertEquals($subject, $this->getEmail($message)
230230
->getSubject(), "No email with a subject of $subject was found.");
231231

232232
return $this;
233233
}
234234

235+
/**
236+
* Assert that the last email's subject contains the given string.
237+
*
238+
* @param string $excerpt
239+
* @param Swift_Message|null $message
240+
*
241+
* @return PHPUnit_Framework_TestCase $this
242+
*/
243+
protected function seeEmailSubjectContains($excerpt, Swift_Message $message = null)
244+
{
245+
$this->assertContains($excerpt, $this->getEmail($message)
246+
->getSubject(), "No email containing the provided subject was found.");
247+
248+
return $this;
249+
}
250+
251+
/**
252+
* Assert that the last email's subject does not contain the given string.
253+
*
254+
* @param string $excerpt
255+
* @param Swift_Message|null $message
256+
*
257+
* @return PHPUnit_Framework_TestCase $this
258+
*/
259+
protected function seeEmailSubjectDoesNotContain($excerpt, Swift_Message $message = null)
260+
{
261+
$this->assertNotContains($excerpt, $this->getEmail($message)
262+
->getSubject(),
263+
"Email containing the provided text was found in the subject.");
264+
265+
return $this;
266+
}
267+
235268
/**
236269
* Assert that the last email was sent to the given recipient.
237270
*

0 commit comments

Comments
 (0)