2
2
3
3
namespace Codeception \Module ;
4
4
5
- use Codeception \Module ;
6
5
use GuzzleHttp \Client ;
7
6
use GuzzleHttp \Psr7 \Stream ;
8
7
@@ -61,7 +60,7 @@ public function _initialize()
61
60
{
62
61
$ this ->client = new Client ([
63
62
'base_uri ' => $ this ->baseUrl ,
64
- 'headers ' => [
63
+ 'headers ' => [
65
64
'Api-Token ' => $ this ->config ['client_id ' ],
66
65
],
67
66
]);
@@ -113,10 +112,11 @@ public function receiveAnEmail($params)
113
112
public function fetchLastMessage ()
114
113
{
115
114
$ messages = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages " )->getBody ();
115
+
116
116
if ($ messages instanceof Stream) {
117
117
$ messages = $ messages ->getContents ();
118
118
}
119
-
119
+
120
120
$ messages = json_decode ($ messages , true );
121
121
122
122
return array_shift ($ messages );
@@ -260,7 +260,6 @@ public function seeInEmailHtmlBody($expected)
260
260
public function seeAttachments ($ count )
261
261
{
262
262
$ attachments = $ this ->fetchAttachmentsOfLastMessage ();
263
-
264
263
$ this ->assertEquals ($ count , count ($ attachments ));
265
264
}
266
265
@@ -272,7 +271,6 @@ public function seeAttachments($count)
272
271
public function seeAnAttachment ($ bool )
273
272
{
274
273
$ attachments = $ this ->fetchAttachmentsOfLastMessage ();
275
-
276
274
$ this ->assertEquals ($ bool , count ($ attachments ) > 0 );
277
275
}
278
276
@@ -286,6 +284,7 @@ public function seeAnAttachment($bool)
286
284
public function fetchLastMessages ($ number = 1 )
287
285
{
288
286
$ messages = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages " )->getBody ();
287
+
289
288
if ($ messages instanceof Stream) {
290
289
$ messages = $ messages ->getContents ();
291
290
}
@@ -311,13 +310,14 @@ public function fetchLastMessages($number = 1)
311
310
public function getBccEmailOfMessage ($ messageId )
312
311
{
313
312
$ message = $ this ->client ->get ("inboxes/ {$ this ->config ['inbox_id ' ]}/messages/ $ messageId/body.eml " )->getBody ();
313
+
314
314
if ($ message instanceof Stream) {
315
315
$ message = $ message ->getContents ();
316
316
}
317
317
$ matches = [];
318
318
preg_match ('/Bcc:\s[\w.-]+@[\w.-]+\.[a-z]{2,6}/ ' , $ message , $ matches );
319
319
320
- $ bcc = substr (array_shift ($ matches ),5 );
320
+ $ bcc = substr (array_shift ($ matches ),5 );
321
321
322
322
return $ bcc ;
323
323
}
0 commit comments