setCourse($accompanyingPeriod)->setUser($user1 = new User()); $accompanyingPeriod->setUser($user = new User()); $entityWorkflow = new EntityWorkflow(); $entityWorkflow->setRelatedEntityId(1); $handler = new AccompanyingCourseDocumentWorkflowHandler( $this->prophesize(TranslatorInterface::class)->reveal(), $this->prophesize(EntityWorkflowRepository::class)->reveal(), $this->buildRepository($document, 1), new WorkflowWithPublicViewDocumentHelper($this->prophesize(Environment::class)->reveal()), $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); self::assertCount(2, $users); self::assertContains($user, $users); self::assertContains($user1, $users); } public function testGetSuggestedUsersWithDuplicates() { $accompanyingPeriod = new AccompanyingPeriod(); $document = new AccompanyingCourseDocument(); $document->setCourse($accompanyingPeriod)->setUser($user1 = new User()); $accompanyingPeriod->setUser($user1); $entityWorkflow = new EntityWorkflow(); $entityWorkflow->setRelatedEntityId(1); $handler = new AccompanyingCourseDocumentWorkflowHandler( $this->prophesize(TranslatorInterface::class)->reveal(), $this->prophesize(EntityWorkflowRepository::class)->reveal(), $this->buildRepository($document, 1), new WorkflowWithPublicViewDocumentHelper($this->prophesize(Environment::class)->reveal()), $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); self::assertCount(1, $users); self::assertContains($user1, $users); } private function buildRepository(AccompanyingCourseDocument $document, int $id): AccompanyingCourseDocumentRepository { $repository = $this->prophesize(AccompanyingCourseDocumentRepository::class); $repository->find($id)->willReturn($document); return $repository->reveal(); } }