diff --git a/tests/Unit/Services/TraktServiceTest.php b/tests/Unit/Services/TraktServiceTest.php new file mode 100644 index 000000000..a15f96968 --- /dev/null +++ b/tests/Unit/Services/TraktServiceTest.php @@ -0,0 +1,53 @@ + 'test_trakt_key', + 'nntmux_api.trakttv_timeout' => 30, + 'nntmux_api.trakttv_retry_times' => 1, + 'nntmux_api.trakttv_retry_delay' => 1, + 'cache.default' => 'array', + ]); + + Cache::flush(); + $this->service = new TraktService; + } + + public function test_get_show_summary_accepts_numeric_trakt_id(): void + { + Http::fake([ + 'https://api.trakt.tv/shows/1390*' => Http::response([ + 'title' => 'Breaking Bad', + 'ids' => [ + 'trakt' => 1390, + ], + ], 200), + ]); + + $summary = $this->service->getShowSummary(1390, 'full'); + + $this->assertNotNull($summary); + $this->assertSame('Breaking Bad', $summary['title']); + + Http::assertSent(function ($request) { + return str_contains($request->url(), 'https://api.trakt.tv/shows/1390') + && $request['extended'] === 'full'; + }); + } +}