seasonVoter = new SeasonVoter(); $this->token = $this->createStub(TokenInterface::class); $user = $this->createStub(User::class); $this->token->method('getUser')->willReturn($user); } #[DataProvider('typesProvider')] public function testWithTypes(mixed $subject): void { $this->assertSame(VoterInterface::ACCESS_GRANTED, $this->seasonVoter->vote($this->token, $subject, ['SEASON_EDIT'])); } public function testNotOwnerWillReturnDenied(): void { $season = self::createStub(Season::class); $season->method('isOwner')->willReturn(false); $this->assertSame(VoterInterface::ACCESS_DENIED, $this->seasonVoter->vote($this->token, $season, ['SEASON_EDIT'])); } public static function typesProvider(): \Generator { $season = self::createStub(Season::class); $season->method('isOwner')->willReturn(true); $quiz = self::createStub(Quiz::class); $quiz->method('getSeason')->willReturn($season); $elimination = self::createStub(Elimination::class); $elimination->method('getQuiz')->willReturn($quiz); $candidate = self::createStub(Candidate::class); $candidate->method('getSeason')->willReturn($season); $question = self::createStub(Question::class); $question->method('getQuiz')->willReturn($quiz); $answer = self::createStub(Answer::class); $answer->method('getQuestion')->willReturn($question); yield 'Season' => [$season]; yield 'Elimination' => [$elimination]; yield 'Quiz' => [$quiz]; yield 'Candidate' => [$candidate]; yield 'Question' => [$question]; yield 'Answer' => [$answer]; } }