From b040f02e0c9e05abd72e418514c247841562bec5 Mon Sep 17 00:00:00 2001 From: ilumos Date: Sat, 31 Jan 2026 14:59:48 +0000 Subject: [PATCH 1/4] If API returns no games, return an empty collection --- src/Requests/GetRecentlyPlayedGamesRequest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Requests/GetRecentlyPlayedGamesRequest.php b/src/Requests/GetRecentlyPlayedGamesRequest.php index 678bc55..5967a53 100644 --- a/src/Requests/GetRecentlyPlayedGamesRequest.php +++ b/src/Requests/GetRecentlyPlayedGamesRequest.php @@ -37,6 +37,11 @@ public function defaultQuery(): array public function createDtoFromResponse(Response $response): Collection { - return new Collection(RecentlyPlayedApp::collect($response->json('response.games'))); + $games = $response->json('response.games'); + if($games !== null) { + return new Collection(RecentlyPlayedApp::collect($games)); + } else { + return new Collection(); + } } } From 9c13e6a982f02d47322791abeaced6b795e63ddc Mon Sep 17 00:00:00 2001 From: ilumos Date: Mon, 2 Feb 2026 18:50:21 +0000 Subject: [PATCH 2/4] Fix code style --- src/Requests/GetRecentlyPlayedGamesRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Requests/GetRecentlyPlayedGamesRequest.php b/src/Requests/GetRecentlyPlayedGamesRequest.php index 5967a53..9f80639 100644 --- a/src/Requests/GetRecentlyPlayedGamesRequest.php +++ b/src/Requests/GetRecentlyPlayedGamesRequest.php @@ -38,10 +38,10 @@ public function defaultQuery(): array public function createDtoFromResponse(Response $response): Collection { $games = $response->json('response.games'); - if($games !== null) { + if ($games !== null) { return new Collection(RecentlyPlayedApp::collect($games)); } else { - return new Collection(); + return new Collection; } } } From 789476a27b552ce3936fc20439d4ce3cb64339b2 Mon Sep 17 00:00:00 2001 From: ilumos Date: Sat, 7 Feb 2026 23:30:39 +0000 Subject: [PATCH 3/4] Add test for empty responses --- tests/Datasets/users.php | 4 ++++ .../Requests/GetRecentlyPlayedGamesRequestTest.php | 7 +++++++ .../v1/steamid=76561197960287930.json | 14 ++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/Fixtures/Saloon/api.steampowered.com/GET/IPlayerService/GetRecentlyPlayedGames/v1/steamid=76561197960287930.json diff --git a/tests/Datasets/users.php b/tests/Datasets/users.php index 3abfb15..6bbcc4c 100644 --- a/tests/Datasets/users.php +++ b/tests/Datasets/users.php @@ -3,3 +3,7 @@ dataset('userids', function (): iterable { yield 'Gummibeer' => 76561198061912622; }); + +dataset('privateuserids', function (): iterable { + yield 'Rabscuttle' => 76561197960287930; +}); \ No newline at end of file diff --git a/tests/Feature/Requests/GetRecentlyPlayedGamesRequestTest.php b/tests/Feature/Requests/GetRecentlyPlayedGamesRequestTest.php index b62e37b..9db9263 100644 --- a/tests/Feature/Requests/GetRecentlyPlayedGamesRequestTest.php +++ b/tests/Feature/Requests/GetRecentlyPlayedGamesRequestTest.php @@ -10,3 +10,10 @@ Assert::assertContainsOnlyInstancesOf(RecentlyPlayedApp::class, $apps); })->with('userids'); + +it('returns an empty collection', function (string $steamid): void { + $apps = app(SteamConnector::class)->getRecentlyPlayedGames(steamid: $steamid); + + Assert::assertEmpty($apps); + +})->with('privateuserids'); diff --git a/tests/Fixtures/Saloon/api.steampowered.com/GET/IPlayerService/GetRecentlyPlayedGames/v1/steamid=76561197960287930.json b/tests/Fixtures/Saloon/api.steampowered.com/GET/IPlayerService/GetRecentlyPlayedGames/v1/steamid=76561197960287930.json new file mode 100644 index 0000000..5bca6ff --- /dev/null +++ b/tests/Fixtures/Saloon/api.steampowered.com/GET/IPlayerService/GetRecentlyPlayedGames/v1/steamid=76561197960287930.json @@ -0,0 +1,14 @@ +{ + "statusCode": 200, + "headers": { + "Server": "nginx", + "Content-Type": "application\/json; charset=UTF-8", + "X-eresult": "15", + "Expires": "Sat, 07 Feb 2026 23:24:13 GMT", + "Date": "Sat, 07 Feb 2026 23:24:13 GMT", + "Content-Length": "15", + "Connection": "keep-alive" + }, + "data": "{\"response\":{}}", + "context": [] +} \ No newline at end of file From c2680ced1c7435a4d0e213172f58beaa62691982 Mon Sep 17 00:00:00 2001 From: ilumos Date: Sun, 8 Feb 2026 12:00:01 +0000 Subject: [PATCH 4/4] Fix code style --- tests/Datasets/users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Datasets/users.php b/tests/Datasets/users.php index 6bbcc4c..669f19a 100644 --- a/tests/Datasets/users.php +++ b/tests/Datasets/users.php @@ -6,4 +6,4 @@ dataset('privateuserids', function (): iterable { yield 'Rabscuttle' => 76561197960287930; -}); \ No newline at end of file +});