2626trait MailTracking
2727{
2828 // TODO: Add check for attachments (number of & name)
29- // TODO: Add check for BCC
30- // TODO: Add check for CC
3129 // TODO: Add check for header
3230 // TODO: Add check for message type
3331 // TODO: Add check for Priority
34- // TODO: Add check for ReplyTo
3532 // TODO: Allow checking specific message not just most recent one
3633
3734 /**
@@ -58,7 +55,7 @@ public function setUpMailTracking()
5855 /**
5956 * Retrieve the appropriate swift message.
6057 *
61- * @param Swift_Message $message
58+ * @param Swift_Message|null $message
6259 *
6360 * @return Swift_Message
6461 */
@@ -89,11 +86,43 @@ public function recordMail(Swift_Message $email)
8986 $ this ->emails [] = $ email ;
9087 }
9188
89+ /**
90+ * Assert that the last email was bcc'ed to the given address.
91+ *
92+ * @param string $bcc
93+ * @param Swift_Message|null $message
94+ *
95+ * @return PHPUnit_Framework_TestCase $this
96+ */
97+ protected function seeEmailBcc ($ bcc , Swift_Message $ message = null )
98+ {
99+ $ this ->assertArrayHasKey ($ bcc , (array )$ this ->getEmail ($ message )
100+ ->getBcc (), "No email was bcc'ed to $ bcc. " );
101+
102+ return $ this ;
103+ }
104+
105+ /**
106+ * Assert that the last email was cc'ed to the given address.
107+ *
108+ * @param string $cc
109+ * @param Swift_Message|null $message
110+ *
111+ * @return PHPUnit_Framework_TestCase $this
112+ */
113+ protected function seeEmailCc ($ cc , Swift_Message $ message = null )
114+ {
115+ $ this ->assertArrayHasKey ($ cc , (array )$ this ->getEmail ($ message )
116+ ->getCc (), "No email was cc'ed to $ cc. " );
117+
118+ return $ this ;
119+ }
120+
92121 /**
93122 * Assert that the last email's body contains the given text.
94123 *
95- * @param string $excerpt
96- * @param Swift_Message $message
124+ * @param string $excerpt
125+ * @param Swift_Message|null $message
97126 *
98127 * @return PHPUnit_Framework_TestCase $this
99128 */
@@ -108,8 +137,8 @@ protected function seeEmailContains($excerpt, Swift_Message $message = null)
108137 /**
109138 * Assert that the last email's body equals the given text.
110139 *
111- * @param string $body
112- * @param Swift_Message $message
140+ * @param string $body
141+ * @param Swift_Message|null $message
113142 *
114143 * @return PHPUnit_Framework_TestCase $this
115144 */
@@ -124,8 +153,8 @@ protected function seeEmailEquals($body, Swift_Message $message = null)
124153 /**
125154 * Assert that the last email was delivered by the given address.
126155 *
127- * @param string $sender
128- * @param Swift_Message $message
156+ * @param string $sender
157+ * @param Swift_Message|null $message
129158 *
130159 * @return PHPUnit_Framework_TestCase $this
131160 */
@@ -138,6 +167,22 @@ protected function seeEmailFrom($sender, Swift_Message $message = null)
138167 return $ this ;
139168 }
140169
170+ /**
171+ * Assert that the last email was set to reply to the given address.
172+ *
173+ * @param string $reply_to
174+ * @param Swift_Message|null $message
175+ *
176+ * @return PHPUnit_Framework_TestCase $this
177+ */
178+ protected function seeEmailReplyTo ($ reply_to , Swift_Message $ message = null )
179+ {
180+ $ this ->assertArrayHasKey ($ reply_to , (array )$ this ->getEmail ($ message )
181+ ->getReplyTo (), "No email was set to reply to $ reply_to. " );
182+
183+ return $ this ;
184+ }
185+
141186 /**
142187 * Assert that the given number of emails were sent.
143188 *
@@ -157,8 +202,8 @@ protected function seeEmailsSent($count)
157202 /**
158203 * Assert that the last email's subject matches the given string.
159204 *
160- * @param string $subject
161- * @param Swift_Message $message
205+ * @param string $subject
206+ * @param Swift_Message|null $message
162207 *
163208 * @return PHPUnit_Framework_TestCase $this
164209 */
@@ -174,8 +219,8 @@ protected function seeEmailSubject($subject, Swift_Message $message = null)
174219 /**
175220 * Assert that the last email was sent to the given recipient.
176221 *
177- * @param string $recipient
178- * @param Swift_Message $message
222+ * @param string $recipient
223+ * @param Swift_Message|null $message
179224 *
180225 * @return PHPUnit_Framework_TestCase $this
181226 */
0 commit comments