Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99bea35

Browse files
committed
[Mailer] [Scaleway] Improved unit test to check attachments' serialization
1 parent d8a4a93 commit 99bea35

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Symfony/Component/Mailer/Bridge/Scaleway/Tests/Transport/ScalewayApiTransportTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Mailer\Exception\HttpTransportException;
1919
use Symfony\Component\Mime\Address;
2020
use Symfony\Component\Mime\Email;
21+
use Symfony\Component\Mime\Part\DataPart;
2122
use Symfony\Contracts\HttpClient\ResponseInterface;
2223

2324
class ScalewayApiTransportTest extends TestCase
@@ -64,6 +65,10 @@ public function testSend()
6465
$this->assertSame(['email' => '[email protected]', 'name' => 'Saif Eddin'], $body['to'][0]);
6566
$this->assertSame('Hello!', $body['subject']);
6667
$this->assertSame('Hello There!', $body['text']);
68+
$this->assertSame(1, count($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']);
6772

6873
return new JsonMockResponse(['emails' => [['message_id' => 'foobar']]], [
6974
'http_code' => 200,
@@ -76,7 +81,8 @@ public function testSend()
7681
$mail->subject('Hello!')
7782
->to(new Address('[email protected]', 'Saif Eddin'))
7883
->from(new Address('[email protected]', 'Fabien'))
79-
->text('Hello There!');
84+
->text('Hello There!')
85+
->addPart(new DataPart('some attachment', 'attachment.txt', 'text/plain'));
8086

8187
$message = $transport->send($mail);
8288

0 commit comments

Comments
 (0)