18
18
use Symfony \Component \Mailer \Exception \HttpTransportException ;
19
19
use Symfony \Component \Mime \Address ;
20
20
use Symfony \Component \Mime \Email ;
21
+ use Symfony \Component \Mime \Part \DataPart ;
21
22
use Symfony \Contracts \HttpClient \ResponseInterface ;
22
23
23
24
class ScalewayApiTransportTest extends TestCase
@@ -64,6 +65,10 @@ public function testSend()
64
65
$ this ->
assertSame ([
'email ' =>
'[email protected] ' ,
'name ' =>
'Saif Eddin ' ],
$ body[
'to ' ][
0 ]);
65
66
$ this ->assertSame ('Hello! ' , $ body ['subject ' ]);
66
67
$ this ->assertSame ('Hello There! ' , $ body ['text ' ]);
68
+ $ this ->assertCount (1 , $ body ['attachments ' ]);
69
+ $ this ->assertSame ('attachment.txt ' , $ body ['attachments ' ][0 ]['name ' ]);
70
+ $ this ->assertSame ('text/plain ' , $ body ['attachments ' ][0 ]['type ' ]);
71
+ $ this ->assertSame (base64_encode ('some attachment ' ), $ body ['attachments ' ][0 ]['content ' ]);
67
72
68
73
return new JsonMockResponse (['emails ' => [['message_id ' => 'foobar ' ]]], [
69
74
'http_code ' => 200 ,
@@ -76,7 +81,8 @@ public function testSend()
76
81
$ mail ->subject ('Hello! ' )
77
82
->
to (
new Address (
'[email protected] ' ,
'Saif Eddin ' ))
78
83
->
from (
new Address (
'[email protected] ' ,
'Fabien ' ))
79
- ->text ('Hello There! ' );
84
+ ->text ('Hello There! ' )
85
+ ->addPart (new DataPart ('some attachment ' , 'attachment.txt ' , 'text/plain ' ));
80
86
81
87
$ message = $ transport ->send ($ mail );
82
88
0 commit comments