60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Email;
|
|
|
|
use App\Email\Mailer;
|
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
/**
|
|
* What a mail carries for the transport it goes out over, built through the real template stack.
|
|
*/
|
|
class MailerTest extends KernelTestCase
|
|
{
|
|
/**
|
|
* Mailjet would otherwise track opens and rewrite links if the account is set to, which staff
|
|
* mail - mailings and reminders alike - must not be.
|
|
*/
|
|
public function testMailOverMailjetIsNotTracked(): void
|
|
{
|
|
$headers = $this->create(Mailer::MAILJET_TRANSPORT)->getHeaders();
|
|
|
|
$this->assertSame(Mailer::MAILJET_TRANSPORT, $headers->get('X-Transport')?->getBodyAsString());
|
|
$this->assertSame('0', $headers->get('X-Mailjet-TrackOpen')?->getBodyAsString());
|
|
$this->assertSame('0', $headers->get('X-Mailjet-TrackClick')?->getBodyAsString());
|
|
}
|
|
|
|
/**
|
|
* The webhoster's relay would pass Mailjet headers on to the recipient as noise.
|
|
*/
|
|
public function testMailOverTheRelayCarriesNoMailjetHeaders(): void
|
|
{
|
|
$headers = $this->create(null)->getHeaders();
|
|
|
|
$this->assertFalse($headers->has('X-Transport'));
|
|
$this->assertFalse($headers->has('X-Mailjet-TrackOpen'));
|
|
$this->assertFalse($headers->has('X-Mailjet-TrackClick'));
|
|
}
|
|
|
|
/**
|
|
* Mailer::create() takes the options as createAndSendEmail() has resolved them.
|
|
*/
|
|
private function create(?string $transport): TemplatedEmail
|
|
{
|
|
self::bootKernel();
|
|
|
|
return self::getContainer()->get(Mailer::class)->create(['feedbacks' => []], [
|
|
'from' => '[email protected]',
|
|
'to' => '[email protected]',
|
|
'subject' => 'Betreff',
|
|
'subject_parameters' => [],
|
|
'template' => 'email/reminder_pending_feedback.html.twig',
|
|
'attachments' => [],
|
|
'transport' => $transport,
|
|
'bus_transport' => null,
|
|
]);
|
|
}
|
|
}
|