setUser($referrer = new User()); $accompanyingCourse->addWork($work = new AccompanyingPeriod\AccompanyingPeriodWork()); $work->addReferrer($workReferrer1 = new User()); $work->addReferrer($workReferrer2 = new User()); $work->addReferrer($referrer); $work->addAccompanyingPeriodWorkEvaluation($eval = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation()); $entityWorkflow = new EntityWorkflow(); $entityWorkflow->setRelatedEntityId(1); // Prophesize each dependency $workflowRepositoryProphecy = $this->prophesize(EntityWorkflowRepository::class); $translatableStringHelperProphecy = $this->prophesize(TranslatableStringHelperInterface::class); $translatorProphecy = $this->prophesize(TranslatorInterface::class); // Create an instance of the class under test using revealed prophecies directly $handler = new AccompanyingPeriodWorkEvaluationWorkflowHandler( $this->buildRepository($eval, 1), $workflowRepositoryProphecy->reveal(), $translatableStringHelperProphecy->reveal(), $translatorProphecy->reveal(), $this->prophesize(ProvideThirdPartiesAssociated::class)->reveal(), $this->prophesize(ProvidePersonsAssociated::class)->reveal(), ); $users = $handler->getSuggestedUsers($entityWorkflow); self::assertContains($referrer, $users); self::assertContains($workReferrer1, $users); self::assertContains($workReferrer2, $users); } private function buildRepository(AccompanyingPeriod\AccompanyingPeriodWorkEvaluation $evaluation, int $id): AccompanyingPeriodWorkEvaluationRepository { $evaluationRepositoryProphecy = $this->prophesize(AccompanyingPeriodWorkEvaluationRepository::class); $evaluationRepositoryProphecy->find($id)->willReturn($evaluation); return $evaluationRepositoryProphecy->reveal(); } }