Automatically execute body renderer when posting an email in Chill

+ adaptation of services which already uses body renderer
This commit is contained in:
2024-10-10 14:06:00 +02:00
parent 3d53e7da65
commit 1313b6f138
3 changed files with 15 additions and 6 deletions

View File

@@ -14,6 +14,8 @@ namespace Chill\MainBundle\Tests\Workflow\Messenger;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Chill\MainBundle\Workflow\Messenger\PostSendExternalMessage;
use Chill\MainBundle\Workflow\Messenger\PostSendExternalMessageHandler;
use Chill\MainBundle\Workflow\WorkflowTransitionContextDTO;
@@ -25,6 +27,7 @@ use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\BodyRendererInterface;
use Symfony\Component\Workflow\Registry;
/**
* @internal
@@ -50,10 +53,12 @@ class PostSendExternalMessageHandlerTest extends TestCase
$mailer->send(Argument::that($this->buildCheckAddressCallback('3party@example.com')))->shouldBeCalledOnce();
$mailer->send(Argument::that($this->buildCheckAddressCallback('external@example.com')))->shouldBeCalledOnce();
$bodyRenderer = $this->prophesize(BodyRendererInterface::class);
$bodyRenderer->render(Argument::type(TemplatedEmail::class))->shouldBeCalledTimes(2);
$workflowHandler = $this->prophesize(EntityWorkflowHandlerInterface::class);
$workflowHandler->getEntityTitle($entityWorkflow, Argument::any())->willReturn('title');
$workflowManager = $this->prophesize(EntityWorkflowManager::class);
$workflowManager->getHandler($entityWorkflow)->willReturn($workflowHandler->reveal());
$handler = new PostSendExternalMessageHandler($repository->reveal(), $mailer->reveal(), $bodyRenderer->reveal());
$handler = new PostSendExternalMessageHandler($repository->reveal(), $mailer->reveal(), $workflowManager->reveal());
$handler(new PostSendExternalMessage(1, 'fr'));