feat: list the other recipients and reply to the sender in assignment mailings
This commit is contained in:
1 parent
e0496dc61f
commit
f45ac6ac0b
15 files changed
+311
-19
No files matched your search
@@ -247,6 +247,97 @@ class TeamerMailingServiceTest extends TestCase
|
||||
$this->assertSame([], $mailing->getAttachments());
|
||||
}
|
||||
|
||||
public function testSendMailingListsEveryOtherRecipientAsColleague(): void
|
||||
{
|
||||
$colleagues = [];
|
||||
$this->mailer
|
||||
->expects($this->exactly(3))
|
||||
->method('createAndSendEmail')
|
||||
->willReturnCallback(function (array $context, array $options) use (&$colleagues): void {
|
||||
$colleagues[$options['to']] = array_column($context['colleagues'], 'email', 'fullName');
|
||||
})
|
||||
;
|
||||
|
||||
$recipients = (new TeamerMailingRecipientsDto())
|
||||
->addEligible($this->createRecipient('Anna', 'Berg', '[email protected]'))
|
||||
->addEligible($this->createRecipient('Bea', 'Ohm', '[email protected]'))
|
||||
->addEligible($this->createRecipient('Cem', 'Dal', '[email protected]'))
|
||||
;
|
||||
|
||||
$this->service->sendMailing(SendTeamerMailing::fromRecipients('Betreff', 'Nachricht', $recipients, listColleagues: true));
|
||||
|
||||
$this->assertSame([
|
||||
'[email protected]' => ['Bea Ohm' => '[email protected]', 'Cem Dal' => '[email protected]'],
|
||||
'[email protected]' => ['Anna Berg' => '[email protected]', 'Cem Dal' => '[email protected]'],
|
||||
'[email protected]' => ['Anna Berg' => '[email protected]', 'Bea Ohm' => '[email protected]'],
|
||||
], $colleagues);
|
||||
}
|
||||
|
||||
public function testASingleRecipientHasNoColleagues(): void
|
||||
{
|
||||
$this->mailer
|
||||
->expects($this->once())
|
||||
->method('createAndSendEmail')
|
||||
->willReturnCallback(function (array $context): void {
|
||||
$this->assertSame([], $context['colleagues']);
|
||||
})
|
||||
;
|
||||
|
||||
$recipients = (new TeamerMailingRecipientsDto())->addEligible($this->createRecipient('Anna', 'Berg', '[email protected]'));
|
||||
|
||||
$this->service->sendMailing(SendTeamerMailing::fromRecipients('Betreff', 'Nachricht', $recipients, listColleagues: true));
|
||||
}
|
||||
|
||||
/**
|
||||
* The teamer mailing writes to whoever a filter matched - people who need not know each other.
|
||||
*/
|
||||
public function testAMailingWithoutTheFlagListsNoColleagues(): void
|
||||
{
|
||||
$this->mailer
|
||||
->expects($this->exactly(2))
|
||||
->method('createAndSendEmail')
|
||||
->willReturnCallback(function (array $context): void {
|
||||
$this->assertSame([], $context['colleagues']);
|
||||
})
|
||||
;
|
||||
|
||||
$this->service->sendMailing($this->createMailing(
|
||||
'Betreff',
|
||||
'Nachricht',
|
||||
$this->createRecipient('Anna', 'Berg', '[email protected]'),
|
||||
$this->createRecipient('Bea', 'Ohm', '[email protected]')
|
||||
));
|
||||
}
|
||||
|
||||
public function testAMailingQueuedWithoutTheNewOptionsHasNone(): void
|
||||
{
|
||||
$mailing = (new \ReflectionClass(SendTeamerMailing::class))->newInstanceWithoutConstructor();
|
||||
|
||||
$this->assertFalse($mailing->listsColleagues());
|
||||
$this->assertNull($mailing->getReplyTo());
|
||||
}
|
||||
|
||||
public function testSendMailingSetsTheReplyToOnEveryMail(): void
|
||||
{
|
||||
$replyTo = [];
|
||||
$this->mailer
|
||||
->expects($this->exactly(2))
|
||||
->method('createAndSendEmail')
|
||||
->willReturnCallback(function (array $context, array $options) use (&$replyTo): void {
|
||||
$replyTo[] = $options['reply_to'];
|
||||
})
|
||||
;
|
||||
|
||||
$recipients = (new TeamerMailingRecipientsDto())
|
||||
->addEligible($this->createRecipient('Anna', 'Berg', '[email protected]'))
|
||||
->addEligible($this->createRecipient('Bea', 'Ohm', '[email protected]'))
|
||||
;
|
||||
|
||||
$this->service->sendMailing(SendTeamerMailing::fromRecipients('Betreff', 'Nachricht', $recipients, replyTo: '[email protected]'));
|
||||
|
||||
$this->assertSame(['[email protected]', '[email protected]'], $replyTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* A preview has to stay on the default relay and the default queue, or composing a
|
||||
* mailing would wait on the same worker the mailing itself is queued behind.
|
||||
@@ -296,7 +387,7 @@ class TeamerMailingServiceTest extends TestCase
|
||||
->expects($this->once())
|
||||
->method('createAndSendEmail')
|
||||
->with(
|
||||
['bodyHtml' => '<p>Servus Rita Kern</p>'],
|
||||
['bodyHtml' => '<p>Servus Rita Kern</p>', 'colleagues' => []],
|
||||
$this->callback(function (array $options): bool {
|
||||
$this->assertSame('[email protected]', $options['to']);
|
||||
$this->assertSame('[Vorschau] Hallo Rita', $options['subject']);
|
||||
|
||||
Reference in new issue
Block a user