prophesize(WorkflowInterface::class); $workflow = $workflowProphecy->reveal(); $entityWorkflow = new EntityWorkflow(); $entityWorkflow ->setWorkflowName('workflow_name') ->setRelatedEntityClass(\stdClass::class) ->setRelatedEntityId(1); // force an id to entityWorkflow: $reflection = new \ReflectionClass($entityWorkflow); $id = $reflection->getProperty('id'); $id->setAccessible(true); $id->setValue($entityWorkflow, 1); $step = new EntityWorkflowStep(); $userGroup = (new UserGroup())->addUser($userInGroup = new User())->addUser($dest); $entityWorkflow->addStep($step); $step ->addDestUser($dest) ->addDestUserGroup($userGroup) ->setCurrentStep('to_state'); $em = $this->prophesize(EntityManagerInterface::class); // we check that both notification has been persisted once, // eliminating doublons $em->persist(Argument::that( fn ($notificationCandidate) => $notificationCandidate instanceof Notification && $notificationCandidate->getAddressees()->contains($dest) ))->shouldBeCalledOnce(); $em->persist(Argument::that( fn ($notificationCandidate) => $notificationCandidate instanceof Notification && $notificationCandidate->getAddressees()->contains($userInGroup) ))->shouldBeCalledOnce(); $engine = $this->prophesize(\Twig\Environment::class); $engine->render(Argument::type('string'), Argument::type('array')) ->willReturn('dummy text'); $extractor = $this->prophesize(MetadataExtractor::class); $extractor->buildArrayPresentationForPlace(Argument::type(EntityWorkflow::class), Argument::any()) ->willReturn([]); $extractor->buildArrayPresentationForWorkflow(Argument::any()) ->willReturn([]); $registry = $this->prophesize(Registry::class); $registry->get(Argument::type(EntityWorkflow::class), Argument::type('string')) ->willReturn($workflow); $security = $this->prophesize(Security::class); $security->getUser()->willReturn($currentUser); $entityWorkflowHandler = $this->prophesize(EntityWorkflowHandlerInterface::class); $entityWorkflowHandler->getEntityTitle($entityWorkflow)->willReturn('workflow title'); $entityWorkflowManager = $this->prophesize(EntityWorkflowManager::class); $entityWorkflowManager->getHandler($entityWorkflow)->willReturn($entityWorkflowHandler->reveal()); $notificationOnTransition = new NotificationOnTransition( $em->reveal(), $engine->reveal(), $extractor->reveal(), $security->reveal(), $registry->reveal(), $entityWorkflowManager->reveal(), ); $event = new Event($entityWorkflow, new Marking(), new Transition('dummy_transition', ['from_state'], ['to_state']), $workflow); $notificationOnTransition->onCompletedSendNotification($event); } }