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

Commit 7593fee

Browse files
authored
Merge branch 'develop' into feature/checkForPriority
2 parents b0a334f + e7df9cf commit 7593fee

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Diff for: readme.md

+1
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+
* seeEmailContentTypeEquals
3536
* seeEmailCountEquals
3637
* seeEmailDoesNotContain
3738
* seeEmailEquals

Diff for: src/MailTracking.php

+18
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,24 @@ protected function seeEmailContains($excerpt, Swift_Message $message = null)
134134
return $this;
135135
}
136136

137+
/**
138+
* Assert that the last email's content type equals the given text.
139+
* For example, "text/plain" and "text/html" are valid content types for an email.
140+
*
141+
* @param string $content_type
142+
* @param Swift_Message|null $message
143+
*
144+
* @return PHPUnit_Framework_TestCase $this
145+
*/
146+
protected function seeEmailContentTypeEquals($content_type, Swift_Message $message = null)
147+
{
148+
$this->assertEquals($content_type, $this->getEmail($message)
149+
->getContentType(),
150+
"The last email sent did not contain the provided body.");
151+
152+
return $this;
153+
}
154+
137155
/**
138156
* Assert that the last email's body does not contain the given text.
139157
*

Diff for: tests/MailTrackingTest.php

+13
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ public function it_checks_email_cc_address()
156156
$this->assertEquals($this->mail_tracking, $this->callProtectedMethod('seeEmailCc', ['cc@domain.tld']));
157157
}
158158

159+
/**
160+
* @test
161+
* @group unit
162+
*/
163+
public function it_checks_email_content_type()
164+
{
165+
$message = $this->makeMessage();
166+
$message->setContentType('text/html');
167+
$this->mail_tracking->recordMail($message);
168+
169+
$this->assertEquals($this->mail_tracking, $this->callProtectedMethod('seeEmailContentTypeEquals', ['text/html']));
170+
}
171+
159172
/**
160173
* @test
161174
* @group unit

0 commit comments

Comments
 (0)