Closed
Description
Symfony version(s) affected
6.2-dev
Description
I test in my project that the context
of the email has got the correct variables being set. But in 6.2 the message collected by the profiler now has an empty context.
How to reproduce
In my case website_name
is being set.
I create the email like so:
$email = (new TemplatedEmail())
->to($toEmailAddress)
->subject($subject)
->htmlTemplate('@SilverbackApiComponents/emails/' . $this->getTemplate())
->context($context);
$context
is:
array:2 [
"user" => 'xxx'
"website_name" => "New Website"
]
I collect the email and context from the profiler in my test:
** @var MessageDataCollector $collector */
$collector = $this->getProfile()->getCollector('mailer');
/** @var TemplatedEmail[] $messages */
$messages = $collector->getEvents()->getMessages();
Assert::assertCount(1, $messages);
Assert::assertInstanceOf(TemplatedEmail::class, $email = $messages[0]);
/** @var TemplatedEmail $email */
$context = $email->getContext();
And in 6.2 beta, the context is an empty array.
Possible Solution
No response
Additional Context
No response