38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Model;
|
|
|
|
use App\Model\EmailAttachmentDto;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
|
|
|
class EmailAttachmentDtoTest extends TestCase
|
|
{
|
|
public function testAttachToAddsContentAttachment(): void
|
|
{
|
|
$dto = new EmailAttachmentDto('invoice.pdf', 'pdf-content', 'application/pdf');
|
|
$email = new TemplatedEmail();
|
|
|
|
$dto->attachTo($email);
|
|
|
|
$attachments = $email->getAttachments();
|
|
$this->assertCount(1, $attachments);
|
|
|
|
$body = $attachments[0]->getBody();
|
|
$this->assertSame('pdf-content', $body);
|
|
$this->assertSame('invoice.pdf', $attachments[0]->getFilename());
|
|
$this->assertSame('application/pdf', $attachments[0]->getMediaType().'/'.$attachments[0]->getMediaSubtype());
|
|
}
|
|
|
|
public function testGettersReturnConstructorValues(): void
|
|
{
|
|
$dto = new EmailAttachmentDto('test.csv', 'csv-data', 'text/csv');
|
|
|
|
$this->assertSame('test.csv', $dto->getName());
|
|
$this->assertSame('csv-data', $dto->getContent());
|
|
$this->assertSame('text/csv', $dto->getMimeType());
|
|
}
|
|
}
|