addPlaces(['initial', 'layout', 'sign']) ->addTransition(new Transition('to_layout', 'initial', 'layout')) ->addTransition(new Transition('to_sign', 'initial', 'sign')) ->build(); $workflow = new Workflow($definition, new EntityWorkflowMarkingStore(), name: 'dummy_workflow'); $registry = new Registry(); $registry->addWorkflow($workflow, new class () implements WorkflowSupportStrategyInterface { public function supports(WorkflowInterface $workflow, object $subject): bool { return true; } }); return $registry; } public function testPutOnHoldPersistence(): void { $entityWorkflow = new EntityWorkflow(); $entityWorkflow->setWorkflowName('dummy_workflow'); $security = $this->createMock(Security::class); $security->method('getUser')->willReturn($user = new User()); $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager->expects($this->once()) ->method('persist') ->with($this->isInstanceOf(EntityWorkflowStepHold::class)); $entityManager->expects($this->once()) ->method('flush'); $urlGenerator = $this->createMock(UrlGeneratorInterface::class); $urlGenerator->method('generate') ->with('chill_main_workflow_show', ['id' => null]) ->willReturn('/some/url'); $controller = new WorkflowOnHoldController($entityManager, $security, $this->buildRegistry(), $urlGenerator); $request = new Request(); $response = $controller->putOnHold($entityWorkflow, $request); self::assertEquals(302, $response->getStatusCode()); } public function testRemoveOnHold(): void { $user = new User(); $entityWorkflow = new EntityWorkflow(); $entityWorkflow->setWorkflowName('dummy_workflow'); $onHold = new EntityWorkflowStepHold($step = $entityWorkflow->getCurrentStep(), $user); $security = $this->createMock(Security::class); $security->method('getUser')->willReturn($user); $entityManager = $this->createMock(EntityManagerInterface::class); $entityManager->expects($this->once()) ->method('remove') ->with($onHold); $entityManager->expects($this->once()) ->method('flush'); $urlGenerator = $this->createMock(UrlGeneratorInterface::class); $urlGenerator->method('generate') ->with('chill_main_workflow_show', ['id' => null]) ->willReturn('/some/url'); $controller = new WorkflowOnHoldController($entityManager, $security, $this->buildRegistry(), $urlGenerator); $response = $controller->removeOnHold($step); self::assertEquals(302, $response->getStatusCode()); } }