@@ -245,4 +245,45 @@ public function testTagAndMetadataHeaders()
245
245
$ this ->assertSame ('blue ' , $ payload ['personalizations ' ][0 ]['custom_args ' ]['Color ' ]);
246
246
$ this ->assertSame ('12345 ' , $ payload ['personalizations ' ][0 ]['custom_args ' ]['Client-ID ' ]);
247
247
}
248
+
249
+ public function testInlineWithCustomContentId ()
250
+ {
251
+ $ imagePart = (new DataPart ('text-contents ' , 'text.txt ' ));
252
+ $ imagePart ->asInline ();
253
+ $ imagePart ->setContentId ('content-identifier@symfony ' );
254
+
255
+ $ email = new Email ();
256
+ $ email ->addPart ($ imagePart );
257
+ $ envelope = new Envelope (new Address ('alice@system.com ' ), [new Address ('bob@system.com ' )]);
258
+
259
+ $ transport = new SendgridApiTransport ('ACCESS_KEY ' );
260
+ $ method = new \ReflectionMethod (SendgridApiTransport::class, 'getPayload ' );
261
+ $ payload = $ method ->invoke ($ transport , $ email , $ envelope );
262
+
263
+ $ this ->assertArrayHasKey ('attachments ' , $ payload );
264
+ $ this ->assertCount (1 , $ payload ['attachments ' ]);
265
+ $ this ->assertArrayHasKey ('content_id ' , $ payload ['attachments ' ][0 ]);
266
+
267
+ $ this ->assertSame ('content-identifier@symfony ' , $ payload ['attachments ' ][0 ]['content_id ' ]);
268
+ }
269
+
270
+ public function testInlineWithoutCustomContentId ()
271
+ {
272
+ $ imagePart = (new DataPart ('text-contents ' , 'text.txt ' ));
273
+ $ imagePart ->asInline ();
274
+
275
+ $ email = new Email ();
276
+ $ email ->addPart ($ imagePart );
277
+ $ envelope = new Envelope (new Address ('alice@system.com ' ), [new Address ('bob@system.com ' )]);
278
+
279
+ $ transport = new SendgridApiTransport ('ACCESS_KEY ' );
280
+ $ method = new \ReflectionMethod (SendgridApiTransport::class, 'getPayload ' );
281
+ $ payload = $ method ->invoke ($ transport , $ email , $ envelope );
282
+
283
+ $ this ->assertArrayHasKey ('attachments ' , $ payload );
284
+ $ this ->assertCount (1 , $ payload ['attachments ' ]);
285
+ $ this ->assertArrayHasKey ('content_id ' , $ payload ['attachments ' ][0 ]);
286
+
287
+ $ this ->assertSame ('text.txt ' , $ payload ['attachments ' ][0 ]['content_id ' ]);
288
+ }
248
289
}
0 commit comments