Correct instantiation of controller within test

This commit is contained in:
Julie Lenaerts 2024-08-30 13:02:39 +02:00 committed by Julien Fastré
parent 745a29f742
commit 8c4f342ca1
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -6,6 +6,7 @@ use Chill\MainBundle\Controller\WorkflowOnHoldController;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepHold; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepHold;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepHoldRepository; use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepHoldRepository;
use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Security\ChillSecurity;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -41,6 +42,7 @@ class WorkflowOnHoldControllerTest extends KernelTestCase
$this->security = $this->createMock(Security::class); $this->security = $this->createMock(Security::class);
$this->registry = $this->createMock(Registry::class); $this->registry = $this->createMock(Registry::class);
$this->entityWorkflowStepHoldRepository = $this->createMock(EntityWorkflowStepHoldRepository::class); $this->entityWorkflowStepHoldRepository = $this->createMock(EntityWorkflowStepHoldRepository::class);
$this->entityWorkflowRepository = $this->createMock(EntityWorkflowRepository::class);
$this->entityWorkflow = $this->createMock(EntityWorkflow::class); $this->entityWorkflow = $this->createMock(EntityWorkflow::class);
$this->workflow = $this->createMock(Workflow::class); $this->workflow = $this->createMock(Workflow::class);
@ -59,7 +61,8 @@ class WorkflowOnHoldControllerTest extends KernelTestCase
$this->entityManager, $this->entityManager,
$this->security, $this->security,
$this->registry, $this->registry,
$this->entityWorkflowStepHoldRepository $this->entityWorkflowStepHoldRepository,
$this->entityWorkflowRepository
); );
} }
@ -85,20 +88,13 @@ class WorkflowOnHoldControllerTest extends KernelTestCase
->method('flush'); ->method('flush');
$request = new Request(); $request = new Request();
$controller->putOnHold($this->entityWorkflow, $request); $this->controller->putOnHold($this->entityWorkflow, $request);
} }
public function testPutOnHoldSmokeTest(): void public function testPutOnHoldSmokeTest(): void
{ {
$controller = new WorkflowOnHoldController(
$this->entityManager,
$this->security,
$this->registry,
$this->entityWorkflowStepHoldRepository
);
$request = new Request(); $request = new Request();
$response = $controller->putOnHold($this->entityWorkflow, $request); $response = $this->controller->putOnHold($this->entityWorkflow, $request);
$this->assertInstanceOf(Response::class, $response); $this->assertInstanceOf(Response::class, $response);
$this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(302, $response->getStatusCode());