mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 16:13:50 +00:00
Persist EntityWorkflow and its steps with EntityManager
Refactored NotificationToUserGroupsOnTransition to utilize EntityManager for persisting EntityWorkflowStep. This ensures entities have generated IDs, leading to proper email notifications during workflow transitions.
This commit is contained in:
@@ -59,9 +59,7 @@ class NotificationToUserGroupsOnTransitionTest extends KernelTestCase
|
||||
public function testOnCompletedSendNotificationToUserGroupWithEmailAddress(): void
|
||||
{
|
||||
$entityWorkflow = new EntityWorkflow();
|
||||
$reflection = new \ReflectionClass($entityWorkflow);
|
||||
$idProperty = $reflection->getProperty('id');
|
||||
$idProperty->setValue($entityWorkflow, 1);
|
||||
$this->em->persist($entityWorkflow);
|
||||
|
||||
$entityWorkflow->setWorkflowName('dummy');
|
||||
$dto = new WorkflowTransitionContextDTO($entityWorkflow);
|
||||
@@ -69,11 +67,7 @@ class NotificationToUserGroupsOnTransitionTest extends KernelTestCase
|
||||
$ug->setEmail('test@email.com')->setLabel(['fr' => 'test group']);
|
||||
|
||||
$mailer = $this->prophesize(MailerInterface::class);
|
||||
$sendMethod = $mailer->send(Argument::that(function (RawMessage $message) use ($entityWorkflow): bool {
|
||||
// we need to set an id to the current step of the entity workflow
|
||||
$this->em->persist($entityWorkflow);
|
||||
$this->em->persist($entityWorkflow->getCurrentStep());
|
||||
|
||||
$sendMethod = $mailer->send(Argument::that(function (RawMessage $message): bool {
|
||||
if (!$message instanceof TemplatedEmail) {
|
||||
return false;
|
||||
}
|
||||
@@ -140,7 +134,7 @@ class NotificationToUserGroupsOnTransitionTest extends KernelTestCase
|
||||
}
|
||||
});
|
||||
|
||||
$notificationEventSubscriber = new NotificationToUserGroupsOnTransition($this->twig, $metadataExtractor, $registry, $mailer);
|
||||
$notificationEventSubscriber = new NotificationToUserGroupsOnTransition($this->twig, $metadataExtractor, $registry, $mailer, $this->em);
|
||||
$eventDispatcher->addSubscriber($notificationEventSubscriber);
|
||||
|
||||
return $registry;
|
||||
|
Reference in New Issue
Block a user