formFactory = self::getContainer()->get('form.factory'); $this->signatureStepStateChanger = self::getContainer()->get(SignatureStepStateChanger::class); $this->chillUrlGenerator = self::getContainer()->get(ChillUrlGeneratorInterface::class); $requestContext = self::getContainer()->get(RequestContext::class); $requestContext->setParameter('_locale', 'fr'); $this->requestStack = self::getContainer()->get(RequestStack::class); } public function testCancelSignatureGet(): void { $entityWorkflow = new EntityWorkflow(); $dto = new WorkflowTransitionContextDTO($entityWorkflow); $dto->futureUserSignature = new User(); $entityWorkflow->setStep('signature', $dto, 'to_signature', new \DateTimeImmutable(), new User()); $signature = $entityWorkflow->getCurrentStep()->getSignatures()->first(); $security = $this->createMock(Security::class); $security->expects($this->once())->method('isGranted') ->with(EntityWorkflowStepSignatureVoter::CANCEL, $signature)->willReturn(true); $entityManager = $this->createMock(EntityManager::class); $twig = $this->createMock(Environment::class); $twig->expects($this->once())->method('render')->withAnyParameters() ->willReturn('template'); $controller = new WorkflowSignatureStateChangeController($entityManager, $security, $this->formFactory, $twig, $this->signatureStepStateChanger, $this->chillUrlGenerator); $request = new Request(); $request->setMethod('GET'); $this->requestStack->push($request); $response = $controller->cancelSignature($signature, $request); self::assertEquals(200, $response->getStatusCode()); } }