-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OriginalToListHeader in Email when use bcc transformation modifier
- Loading branch information
Dumazeau
committed
Jan 15, 2024
1 parent
0e913c7
commit 5bc815a
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RichId\MailerBundle\Domain\Header; | ||
|
||
use Symfony\Component\Mime\Header\UnstructuredHeader; | ||
|
||
final class OriginalToListHeader extends UnstructuredHeader | ||
{ | ||
public const NAME = 'X-Metadata-Original-To-List'; | ||
|
||
/** @var string[] */ | ||
private array $toList; | ||
|
||
/** @param string[] $toList */ | ||
public function __construct(array $toList) | ||
{ | ||
$this->toList = $toList; | ||
|
||
parent::__construct(self::NAME, ''); | ||
} | ||
|
||
/** @return string[] */ | ||
public function getToList(): array | ||
{ | ||
return $this->toList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use RichCongress\TestFramework\TestConfiguration\Annotation\TestConfig; | ||
use RichCongress\TestSuite\TestCase\TestCase; | ||
use RichId\MailerBundle\Domain\Email; | ||
use RichId\MailerBundle\Domain\Header\OriginalToListHeader; | ||
use RichId\MailerBundle\Infrastructure\TestCase\MailerAssertionsTrait; | ||
use RichId\MailerBundle\Tests\Resources\Stub\ParameterBagStub; | ||
use Symfony\Component\Mailer\MailerInterface; | ||
|
@@ -70,6 +71,7 @@ public function testSendEmailMinimumConfiguration(): void | |
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getBcc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
|
||
public function testSendEmailWithReturnPath(): void | ||
|
@@ -96,6 +98,7 @@ public function testSendEmailWithReturnPath(): void | |
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getBcc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
|
||
public function testSendEmailWithBcc(): void | ||
|
@@ -122,6 +125,7 @@ public function testSendEmailWithBcc(): void | |
self::assertNull($email->getReturnPath()); | ||
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
|
||
public function testSendEmailWithYopmailTransformer(): void | ||
|
@@ -149,6 +153,7 @@ public function testSendEmailWithYopmailTransformer(): void | |
self::assertNull($email->getReturnPath()); | ||
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
|
||
public function testSendEmailWithBccTransformer(): void | ||
|
@@ -181,6 +186,10 @@ public function testSendEmailWithBccTransformer(): void | |
self::assertNull($email->getReturnPath()); | ||
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getAttachments()); | ||
|
||
$originalToListHeader = $email->getHeaders()->get(OriginalToListHeader::NAME); | ||
self::assertInstanceOf(OriginalToListHeader::class, $originalToListHeader); | ||
self::assertSame(['[email protected]'], $originalToListHeader->getToList()); | ||
} | ||
|
||
public function testSendEmailWithSubjectPrefix(): void | ||
|
@@ -208,6 +217,7 @@ public function testSendEmailWithSubjectPrefix(): void | |
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getBcc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
|
||
public function testSendEmailWithFooter(): void | ||
|
@@ -229,6 +239,7 @@ public function testSendEmailWithFooter(): void | |
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getBcc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
|
||
public function testSendEmailWithFooterButDisabled(): void | ||
|
@@ -251,5 +262,6 @@ public function testSendEmailWithFooterButDisabled(): void | |
self::assertEmpty($email->getCc()); | ||
self::assertEmpty($email->getBcc()); | ||
self::assertEmpty($email->getAttachments()); | ||
self::assertNull($email->getHeaders()->get(OriginalToListHeader::NAME)); | ||
} | ||
} |