@@ -102,7 +102,7 @@ public function receiveAnEmail($params)
102
102
$ message = $ this ->fetchLastMessage ();
103
103
104
104
foreach ($ params as $ param => $ value ) {
105
- $ this ->assertEquals ($ value , $ message[ $ param] );
105
+ $ this ->assertEquals ($ value , $ message->{ $ param} );
106
106
}
107
107
}
108
108
@@ -121,6 +121,10 @@ public function fetchMessages()
121
121
122
122
$ messages = json_decode ($ messages , true );
123
123
124
+ foreach ($ messages as $ key => $ message ) {
125
+ $ messages [$ key ] = new MailtrapMessage ($ messages );
126
+ }
127
+
124
128
return $ messages ;
125
129
}
126
130
@@ -147,7 +151,7 @@ public function fetchLastMessages($number = 1)
147
151
/**
148
152
* Get the most recent message of the default inbox.
149
153
*
150
- * @return array
154
+ * @return MailtrapMessage
151
155
*/
152
156
public function fetchLastMessage ()
153
157
{
@@ -164,7 +168,7 @@ public function fetchLastMessage()
164
168
public function fetchAttachmentsOfLastMessage ()
165
169
{
166
170
$ email = $ this ->fetchLastMessage ();
167
- $ response = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages/ {$ email[ ' id ' ] }/attachments " )->getBody ();
171
+ $ response = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages/ {$ email-> id }/attachments " )->getBody ();
168
172
169
173
return json_decode ($ response , true );
170
174
}
@@ -179,7 +183,7 @@ public function fetchAttachmentsOfLastMessage()
179
183
public function receiveAnEmailFromEmail ($ senderEmail )
180
184
{
181
185
$ message = $ this ->fetchLastMessage ();
182
- $ this ->assertEquals ($ senderEmail , $ message[ ' from_email ' ] );
186
+ $ this ->assertEquals ($ senderEmail , $ message-> from_email );
183
187
}
184
188
185
189
/**
@@ -192,7 +196,7 @@ public function receiveAnEmailFromEmail($senderEmail)
192
196
public function receiveAnEmailFromName ($ senderName )
193
197
{
194
198
$ message = $ this ->fetchLastMessage ();
195
- $ this ->assertEquals ($ senderName , $ message[ ' from_name ' ] );
199
+ $ this ->assertEquals ($ senderName , $ message-> from_name );
196
200
}
197
201
198
202
/**
@@ -205,7 +209,7 @@ public function receiveAnEmailFromName($senderName)
205
209
public function receiveAnEmailToEmail ($ recipientEmail )
206
210
{
207
211
$ message = $ this ->fetchLastMessage ();
208
- $ this ->assertEquals ($ recipientEmail , $ message[ ' to_email ' ] );
212
+ $ this ->assertEquals ($ recipientEmail , $ message-> to_email );
209
213
}
210
214
211
215
/**
@@ -218,7 +222,7 @@ public function receiveAnEmailToEmail($recipientEmail)
218
222
public function receiveAnEmailToName ($ recipientName )
219
223
{
220
224
$ message = $ this ->fetchLastMessage ();
221
- $ this ->assertEquals ($ recipientName , $ message[ ' to_name ' ] );
225
+ $ this ->assertEquals ($ recipientName , $ message-> to_name );
222
226
}
223
227
224
228
/**
@@ -231,7 +235,7 @@ public function receiveAnEmailToName($recipientName)
231
235
public function receiveAnEmailWithSubject ($ subject )
232
236
{
233
237
$ message = $ this ->fetchLastMessage ();
234
- $ this ->assertEquals ($ subject , $ message[ ' subject ' ] );
238
+ $ this ->assertEquals ($ subject , $ message-> subject );
235
239
}
236
240
237
241
/**
@@ -244,7 +248,7 @@ public function receiveAnEmailWithSubject($subject)
244
248
public function receiveAnEmailWithTextBody ($ textBody )
245
249
{
246
250
$ message = $ this ->fetchLastMessage ();
247
- $ this ->assertEquals ($ textBody , $ message[ ' text_body ' ] );
251
+ $ this ->assertEquals ($ textBody , $ message-> text_body );
248
252
}
249
253
250
254
/**
@@ -257,7 +261,7 @@ public function receiveAnEmailWithTextBody($textBody)
257
261
public function receiveAnEmailWithHtmlBody ($ htmlBody )
258
262
{
259
263
$ message = $ this ->fetchLastMessage ();
260
- $ this ->assertEquals ($ htmlBody , $ message[ ' html_body ' ] );
264
+ $ this ->assertEquals ($ htmlBody , $ message-> html_body );
261
265
}
262
266
263
267
/**
@@ -270,7 +274,7 @@ public function receiveAnEmailWithHtmlBody($htmlBody)
270
274
public function seeInEmailTextBody ($ expected )
271
275
{
272
276
$ email = $ this ->fetchLastMessage ();
273
- $ this ->assertContains ($ expected , $ email[ ' text_body ' ] , 'Email body contains text ' );
277
+ $ this ->assertContains ($ expected , $ email-> text_body , 'Email body contains text ' );
274
278
}
275
279
276
280
/**
@@ -283,7 +287,7 @@ public function seeInEmailTextBody($expected)
283
287
public function seeInEmailHtmlBody ($ expected )
284
288
{
285
289
$ email = $ this ->fetchLastMessage ();
286
- $ this ->assertContains ($ expected , $ email[ ' html_body ' ] , 'Email body contains HTML ' );
290
+ $ this ->assertContains ($ expected , $ email-> html_body , 'Email body contains HTML ' );
287
291
}
288
292
289
293
/**
@@ -296,7 +300,7 @@ public function seeInEmailHtmlBody($expected)
296
300
public function seeInEmailSubject ($ expected )
297
301
{
298
302
$ email = $ this ->fetchLastMessage ();
299
- $ this ->assertContains ($ expected , $ email[ ' subject ' ] , 'Email subject contains text ' );
303
+ $ this ->assertContains ($ expected , $ email-> subject , 'Email subject contains text ' );
300
304
}
301
305
302
306
/**
@@ -387,7 +391,7 @@ public function waitForEmailWithSubject($subject, $timeout = 5)
387
391
$ emails = $ this ->fetchMessages ();
388
392
foreach ($ emails as $ email ) {
389
393
$ constraint = Assert::equalTo ($ subject );
390
- if ($ constraint ->evaluate ($ email[ ' subject ' ] , '' , true )) {
394
+ if ($ constraint ->evaluate ($ email-> subject , '' , true )) {
391
395
return true ;
392
396
}
393
397
}
@@ -414,7 +418,7 @@ public function waitForEmailWithTextInTextBody($text, $timeout = 5)
414
418
$ emails = $ this ->fetchMessages ();
415
419
foreach ($ emails as $ email ) {
416
420
$ constraint = Assert::stringContains ($ text );
417
- if ($ constraint ->evaluate ($ email[ ' text_body ' ] , '' , true )) {
421
+ if ($ constraint ->evaluate ($ email-> text_body , '' , true )) {
418
422
return true ;
419
423
}
420
424
}
@@ -441,7 +445,7 @@ public function waitForEmailWithTextInHTMLBody($text, $timeout = 5)
441
445
$ emails = $ this ->fetchMessages ();
442
446
foreach ($ emails as $ email ) {
443
447
$ constraint = Assert::stringContains ($ text );
444
- if ($ constraint ->evaluate ($ email[ ' html_body ' ] , '' , true )) {
448
+ if ($ constraint ->evaluate ($ email-> html_body , '' , true )) {
445
449
return true ;
446
450
}
447
451
}
0 commit comments