setName('Oscar')->setPattern('Academy Award'); $actor = new Actor(); $actor->setName('Test Actor'); $award = new Award(); $award->setName('Academy Award for Best Actor'); $award->setYear(2020); $award->setActor($actor); $award->setAwardType($awardType); $awardRepository = $this->createMock(AwardRepository::class); $awardRepository->method('find')->with(42)->willReturn($award); $generator = new GameGridProvider( $this->createMock(ActorRepository::class), $this->createMock(MovieRoleRepository::class), $this->createMock(MovieRepository::class), $awardRepository, $this->createMock(EntityManagerInterface::class), ); $row = new GameRow(); $row->setHintType('award'); $row->setHintData('42'); // Use reflection to test the private resolveHintText method $method = new \ReflectionMethod($generator, 'resolveHintText'); $result = $method->invoke($generator, $row); $this->assertSame('Academy Award for Best Actor (2020)', $result); } public function testGenerateHintRespectsAllowedTypes(): void { $movieRoleRepo = $this->createMock(MovieRoleRepository::class); $movieRoleRepo->method('findOneRandomByActor')->willReturn(null); $awardRepo = $this->createMock(AwardRepository::class); $awardRepo->method('findOneRandomByActor')->willReturn(null); $awardRepo->method('findOneRandomByActorAndTypes')->willReturn(null); $generator = new GameGridProvider( $this->createMock(ActorRepository::class), $movieRoleRepo, $this->createMock(MovieRepository::class), $awardRepo, $this->createMock(EntityManagerInterface::class), ); $actor = new Actor(); $actor->setName('Test'); // Only allow 'award' type, but no awards exist → should return null $method = new \ReflectionMethod($generator, 'generateHint'); $result = $method->invoke($generator, $actor, ['award'], null); $this->assertNull($result); } }