feat: send accepted teamer invoices to configurable email inbox

This commit is contained in:
Björn Fromme
2026-03-15 12:42:28 +01:00
parent 3cb5b065f4
commit 3b99757a08
13 changed files with 648 additions and 4 deletions
+37
View File
@@ -0,0 +1,37 @@
<?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());
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace App\Tests\Model;
use App\Model\EmailPathAttachmentDto;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
class EmailPathAttachmentDtoTest extends TestCase
{
public function testAttachToAddsPathAttachment(): void
{
$tmpFile = tempnam(sys_get_temp_dir(), 'test_attachment_');
file_put_contents($tmpFile, 'dummy-pdf-content');
try {
$dto = new EmailPathAttachmentDto($tmpFile, 'invoice.pdf');
$email = new TemplatedEmail();
$dto->attachTo($email);
$attachments = $email->getAttachments();
$this->assertCount(1, $attachments);
$this->assertSame('invoice.pdf', $attachments[0]->getFilename());
$this->assertSame('application/pdf', $attachments[0]->getMediaType().'/'.$attachments[0]->getMediaSubtype());
} finally {
unlink($tmpFile);
}
}
public function testDefaultMimeTypeIsApplicationPdf(): void
{
$dto = new EmailPathAttachmentDto('/tmp/test.pdf', 'test.pdf');
$this->assertSame('application/pdf', $dto->getMimeType());
}
public function testCustomMimeType(): void
{
$dto = new EmailPathAttachmentDto('/tmp/test.csv', 'test.csv', 'text/csv');
$this->assertSame('text/csv', $dto->getMimeType());
}
public function testGettersReturnConstructorValues(): void
{
$dto = new EmailPathAttachmentDto('/var/uploads/file.pdf', 'document.pdf', 'application/pdf');
$this->assertSame('/var/uploads/file.pdf', $dto->getPath());
$this->assertSame('document.pdf', $dto->getName());
$this->assertSame('application/pdf', $dto->getMimeType());
}
}