@@ -241,6 +241,51 @@ public function testSendEmailWithAttachmentsShouldCalledInfobipWithTheRightParam
241
241
);
242
242
}
243
243
244
+ public function testSendEmailWithHeadersShouldCalledInfobipWithTheRightParameters ()
245
+ {
246
+ $ email = $ this ->basicValidEmail ();
247
+ $ email ->getHeaders ()
248
+ ->addTextHeader ('X-Infobip-IntermediateReport ' , 'true ' )
249
+ ->addTextHeader ('X-Infobip-NotifyUrl ' , 'https://foo.bar ' )
250
+ ->addTextHeader ('X-Infobip-NotifyContentType ' , 'application/json ' )
251
+ ->addTextHeader ('X-Infobip-MessageId ' , 'RANDOM-CUSTOM-ID ' );
252
+
253
+ $ this ->transport ->send ($ email );
254
+
255
+ $ options = $ this ->response ->getRequestOptions ();
256
+ $ this ->arrayHasKey ('body ' );
257
+ $ this ->assertStringMatchesFormat (<<<'TXT'
258
+ %a
259
+ --%s
260
+ Content-Type: text/plain; charset=utf-8
261
+ Content-Transfer-Encoding: 8bit
262
+ Content-Disposition: form-data; name="intermediateReport"
263
+
264
+ true
265
+ --%s
266
+ Content-Type: text/plain; charset=utf-8
267
+ Content-Transfer-Encoding: 8bit
268
+ Content-Disposition: form-data; name="notifyUrl"
269
+
270
+ https://foo.bar
271
+ --%s
272
+ Content-Type: text/plain; charset=utf-8
273
+ Content-Transfer-Encoding: 8bit
274
+ Content-Disposition: form-data; name="notifyContentType"
275
+
276
+ application/json
277
+ --%s
278
+ Content-Type: text/plain; charset=utf-8
279
+ Content-Transfer-Encoding: 8bit
280
+ Content-Disposition: form-data; name="messageId"
281
+
282
+ RANDOM-CUSTOM-ID
283
+ --%s--
284
+ TXT,
285
+ $ options ['body ' ]
286
+ );
287
+ }
288
+
244
289
public function testSendMinimalEmailWithSuccess ()
245
290
{
246
291
$ email = (new Email ())
@@ -357,6 +402,31 @@ public function testSendEmailWithAttachmentsWithSuccess()
357
402
);
358
403
}
359
404
405
+ public function testSendEmailWithHeadersWithSuccess ()
406
+ {
407
+ $ email = $ this ->basicValidEmail ();
408
+ $ email ->getHeaders ()
409
+ ->addTextHeader ('X-Infobip-IntermediateReport ' , 'true ' )
410
+ ->addTextHeader ('X-Infobip-NotifyUrl ' , 'https://foo.bar ' )
411
+ ->addTextHeader ('X-Infobip-NotifyContentType ' , 'application/json ' )
412
+ ->addTextHeader ('X-Infobip-MessageId ' , 'RANDOM-CUSTOM-ID ' );
413
+
414
+ $ sentMessage = $ this ->transport ->send ($ email );
415
+
416
+ $ this ->assertInstanceOf (SentMessage::class, $ sentMessage );
417
+ $ this ->assertStringMatchesFormat (
418
+ <<<'TXT'
419
+ %a
420
+ X-Infobip-IntermediateReport: true
421
+ X-Infobip-NotifyUrl: https://foo.bar
422
+ X-Infobip-NotifyContentType: application/json
423
+ X-Infobip-MessageId: RANDOM-CUSTOM-ID
424
+ %a
425
+ TXT,
426
+ $ sentMessage ->toString ()
427
+ );
428
+ }
429
+
360
430
public function testSentMessageShouldCaptureInfobipMessageId ()
361
431
{
362
432
$ this ->response = new MockResponse ('{"messages": [{"messageId": "somexternalMessageId0"}]} ' );
0 commit comments