diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowOnHoldControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowOnHoldControllerTest.php new file mode 100644 index 000000000..b603c0f25 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Controller/WorkflowOnHoldControllerTest.php @@ -0,0 +1,61 @@ +createMock(EntityManagerInterface::class); + $security = $this->createMock(ChillSecurity::class); + $registry = $this->createMock(Registry::class); + $entityWorkflowStepHoldRepository = $this->createMock(EntityWorkflowStepHoldRepository::class); + $entityWorkflow = $this->createMock(EntityWorkflow::class); + $workflow = $this->createMock(Workflow::class); + $request = $this->createMock(Request::class); + $currentStep = $this->createMock(EntityWorkflow::class); // Assuming EntityWorkflow is the type, adjust if needed + $currentUser = $this->createMock(\Chill\MainBundle\Entity\User::class); // Adjust with actual User entity class + + // Define expected behaviors for the mocks + $entityWorkflow->method('getCurrentStep')->willReturn($currentStep); + $security->method('getUser')->willReturn($currentUser); + $entityWorkflow->method('getWorkflowName')->willReturn('workflow_name'); + $registry->method('get')->with($entityWorkflow, 'workflow_name')->willReturn($workflow); + $workflow->method('getEnabledTransitions')->with($entityWorkflow)->willReturn([]); + $entityWorkflow->method('getUsersInvolved')->willReturn([]); + + $entityManager->expects($this->once()) + ->method('persist') + ->with($this->isInstanceOf(EntityWorkflowStepHold::class)); + + $entityManager->expects($this->once()) + ->method('flush'); + + $controller = new WorkflowOnHoldController( + $entityManager, + $security, + $registry, + $entityWorkflowStepHoldRepository + ); + + // Smoke test + $response = $controller->putOnHold($entityWorkflow, $request); + + $this->assertInstanceOf(Response::class, $response); + $this->assertEquals(302, $response->getStatusCode()); + } +}