-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
6.2.0
Description
Prior to 6.2.0, a call to self::getMailerMessage(0)
would return the only message that was sent. After #47191 was merged, this returns a message from the QueueingMessageEvent
, which means it hasn't been rendered via MessageListener
yet.
Given this is just in tests, it's not a critical BC break, but it is a BC break. I'm not sure if getMailerMessage
and getMailerMessages
is really intended to be returning RawMessage
s from QueueingMessageEvent
or not.
How to reproduce
Create templates/test_email.html.twig
<?php
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Mailer\MailerInterface;
class TestCase extends KernelTestCase
{
public function testItSendsAnEmail(): void
{
$mailer = self::getContainer()->get(MailerInterface::class);
$email = (new TemplatedEmail())
->from('from@example.com')
->to('user@example.com')
->htmlTemplate('test_email.html.twig');
$mailer->send($email);
$email = self::getMailerMessage(0);
self::assertNotNull($email->getHtmlBody());
}
}
Possible Solution
Change getMailerMessage
and getMailerMessages
to filter the events to remove QueueingMessageEvent
.
Additional Context
No response