makeMovieServiceForTraktResponse([ 'title' => 'Example Movie', 'year' => 2024, 'ids' => ['trakt' => 12345], 'overview' => 'Test overview', 'tagline' => 'Test tagline', 'genres' => ['Drama'], 'rating' => 7.5, 'votes' => 10, 'language' => 'en', 'runtime' => 100, 'trailer' => '', ]); $this->setMovieServiceProperty($service, 'currentTitle', 'Example Movie'); $this->setMovieServiceProperty($service, 'currentYear', '2024'); $movie = $service->fetchTraktTVProperties('8169446'); $this->assertIsArray($movie); $this->assertSame('Example Movie', $movie['title']); $this->assertSame(2024, $movie['year']); } #[Test] public function it_still_rejects_mismatched_numeric_trakt_years(): void { Cache::flush(); $service = $this->makeMovieServiceForTraktResponse([ 'title' => 'Example Movie', 'year' => 2024, 'ids' => ['trakt' => 12345], ]); $this->setMovieServiceProperty($service, 'currentTitle', 'Example Movie'); $this->setMovieServiceProperty($service, 'currentYear', '2023'); $this->assertFalse($service->fetchTraktTVProperties('8169447')); } /** * @param array $response */ private function makeMovieServiceForTraktResponse(array $response): MovieService { $client = new class($response) extends TraktService { /** * @param array $response */ public function __construct(private array $response) { parent::__construct('test_trakt_key'); } /** * @return array|null */ public function getMovieSummary(string $movie, string $extended = 'min'): ?array { return $this->response; } }; $provider = new TraktProvider; $provider->client = $client; $service = new MovieService; $service->traktTv = $provider; $service->echooutput = false; $this->setMovieServiceProperty($service, 'traktcheck', 'test-key'); return $service; } private function setMovieServiceProperty(MovieService $service, string $property, mixed $value): void { $reflectionProperty = new \ReflectionProperty($service, $property); $reflectionProperty->setValue($service, $value); } }