From 952bfb278b9d6d88bc3423b84281b2d052bfd49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Skowro=C5=84ski?= Date: Tue, 10 Oct 2023 22:07:31 +0200 Subject: [PATCH] Add Steam API client mock --- config/packages/http_client.yaml | 12 + config/services.yaml | 4 + .../DlcFormDtoDataTransformer.php | 4 +- .../ModFormDtoDataTransformer.php | 4 +- .../Steam/Exception/AppNotFoundException.php | 9 - .../WorkshopItemNotFoundException.php | 9 - .../Dto/AppInfoDto.php | 2 +- .../Dto/WorkshopItemInfoDto.php | 2 +- .../Exception/AppNotFoundException.php | 13 + .../Exception/ClientException.php | 2 +- .../WorkshopItemNotFoundException.php | 13 + .../InvalidAppUrlFormatException.php | 2 +- .../InvalidWorkshopItemUrlFormatException.php | 2 +- .../Helper/SteamHelper.php | 6 +- .../SteamApiClient.php | 21 +- .../SteamApiClientInterface.php | 6 +- .../SteamApiClientMockResponseFactory.php | 95 ++++ .../GetPublishedFileDetails/1934142795.json | 44 ++ .../Test/data/appdetails/1227700.json | 433 ++++++++++++++++++ src/Twig/SteamExtension.php | 2 +- .../Dlc/SteamStoreArma3DlcUrlValidator.php | 8 +- .../Dlc/UniqueSteamStoreDlcValidator.php | 4 +- .../Mod/SteamWorkshopArma3ModUrlValidator.php | 8 +- .../Mod/UniqueSteamWorkshopModValidator.php | 4 +- .../Service/Steam/SteamApiClientTest.php | 34 -- .../SteamApiClient/SteamApiClientTest.php | 83 ++++ .../unit/Service/Steam/SteamApiClientTest.php | 83 ---- .../Helper/SteamHelperTest.php | 8 +- 28 files changed, 740 insertions(+), 177 deletions(-) create mode 100644 config/packages/http_client.yaml delete mode 100644 src/Service/Steam/Exception/AppNotFoundException.php delete mode 100644 src/Service/Steam/Exception/WorkshopItemNotFoundException.php rename src/Service/{Steam => SteamApiClient}/Dto/AppInfoDto.php (92%) rename src/Service/{Steam => SteamApiClient}/Dto/WorkshopItemInfoDto.php (91%) create mode 100644 src/Service/SteamApiClient/Exception/AppNotFoundException.php rename src/Service/{Steam => SteamApiClient}/Exception/ClientException.php (62%) create mode 100644 src/Service/SteamApiClient/Exception/WorkshopItemNotFoundException.php rename src/Service/{Steam => SteamApiClient}/Helper/Exception/InvalidAppUrlFormatException.php (62%) rename src/Service/{Steam => SteamApiClient}/Helper/Exception/InvalidWorkshopItemUrlFormatException.php (64%) rename src/Service/{Steam => SteamApiClient}/Helper/SteamHelper.php (88%) rename src/Service/{Steam => SteamApiClient}/SteamApiClient.php (77%) rename src/Service/{Steam => SteamApiClient}/SteamApiClientInterface.php (59%) create mode 100644 src/Service/SteamApiClient/Test/SteamApiClientMockResponseFactory.php create mode 100644 src/Service/SteamApiClient/Test/data/GetPublishedFileDetails/1934142795.json create mode 100644 src/Service/SteamApiClient/Test/data/appdetails/1227700.json delete mode 100644 tests/integration/Service/Steam/SteamApiClientTest.php create mode 100644 tests/integration/Service/SteamApiClient/SteamApiClientTest.php delete mode 100644 tests/unit/Service/Steam/SteamApiClientTest.php rename tests/unit/Service/{Steam => SteamApiClient}/Helper/SteamHelperTest.php (88%) diff --git a/config/packages/http_client.yaml b/config/packages/http_client.yaml new file mode 100644 index 00000000..c7563762 --- /dev/null +++ b/config/packages/http_client.yaml @@ -0,0 +1,12 @@ +framework: + http_client: + scoped_clients: + client.steam_api: + scope: 'https://(api|store).steampowered.com' + +when@test: + services: + client.steam_api: + class: Symfony\Component\HttpClient\MockHttpClient + arguments: + $responseFactory: '@App\Service\SteamApiClient\Test\SteamApiClientMockResponseFactory' diff --git a/config/services.yaml b/config/services.yaml index 5e54c71c..36524378 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -81,6 +81,10 @@ services: arguments: $storagePath: '%kernel.project_dir%/var/cache_http/%kernel.environment%' + App\Service\SteamApiClient\SteamApiClient: + arguments: + $httpClient: '@client.steam_api' + App\Service\Version\VersionProvider: arguments: $projectDir: '%kernel.project_dir%' diff --git a/src/Form/Dlc/DataTransformer/DlcFormDtoDataTransformer.php b/src/Form/Dlc/DataTransformer/DlcFormDtoDataTransformer.php index 03ac8162..f4ca3a89 100644 --- a/src/Form/Dlc/DataTransformer/DlcFormDtoDataTransformer.php +++ b/src/Form/Dlc/DataTransformer/DlcFormDtoDataTransformer.php @@ -9,8 +9,8 @@ use App\Form\Dlc\Dto\DlcFormDto; use App\Form\FormDtoInterface; use App\Form\RegisteredDataTransformerInterface; -use App\Service\Steam\Helper\SteamHelper; -use App\Service\Steam\SteamApiClientInterface; +use App\Service\SteamApiClient\Helper\SteamHelper; +use App\Service\SteamApiClient\SteamApiClientInterface; use Ramsey\Uuid\Uuid; class DlcFormDtoDataTransformer implements RegisteredDataTransformerInterface diff --git a/src/Form/Mod/DataTransformer/ModFormDtoDataTransformer.php b/src/Form/Mod/DataTransformer/ModFormDtoDataTransformer.php index b4d815ec..d29732c6 100644 --- a/src/Form/Mod/DataTransformer/ModFormDtoDataTransformer.php +++ b/src/Form/Mod/DataTransformer/ModFormDtoDataTransformer.php @@ -14,8 +14,8 @@ use App\Form\FormDtoInterface; use App\Form\Mod\Dto\ModFormDto; use App\Form\RegisteredDataTransformerInterface; -use App\Service\Steam\Helper\SteamHelper; -use App\Service\Steam\SteamApiClientInterface; +use App\Service\SteamApiClient\Helper\SteamHelper; +use App\Service\SteamApiClient\SteamApiClientInterface; use Ramsey\Uuid\Uuid; class ModFormDtoDataTransformer implements RegisteredDataTransformerInterface diff --git a/src/Service/Steam/Exception/AppNotFoundException.php b/src/Service/Steam/Exception/AppNotFoundException.php deleted file mode 100644 index 41d0ab12..00000000 --- a/src/Service/Steam/Exception/AppNotFoundException.php +++ /dev/null @@ -1,9 +0,0 @@ -toArray(); $responseKey = $responseArray['response']; - $itemsCount = $responseKey['resultcount']; - if (1 !== $itemsCount) { - throw new WorkshopItemNotFoundException(sprintf('No items found by item id "%s"!', $itemId)); + $publishedFileDetails = $responseKey['publishedfiledetails'][0] ?? null; + + $timeCreated = $publishedFileDetails['time_created'] ?? null; + if (!$timeCreated) { + throw WorkshopItemNotFoundException::createForItemId($itemId); } - $publishedFileDetails = $responseKey['publishedfiledetails'][0] ?? null; $name = $publishedFileDetails['title'] ?? null; $gameId = $publishedFileDetails['creator_app_id'] ?? null; @@ -57,7 +58,7 @@ public function getAppInfo(int $appId): AppInfoDto $responseKey = $responseArray[$appId]; $success = $responseKey['success']; if (!$success) { - throw new AppNotFoundException(sprintf('No apps found by app id "%s"!', $appId)); + throw AppNotFoundException::createForAppId($appId); } $data = $responseKey['data']; diff --git a/src/Service/Steam/SteamApiClientInterface.php b/src/Service/SteamApiClient/SteamApiClientInterface.php similarity index 59% rename from src/Service/Steam/SteamApiClientInterface.php rename to src/Service/SteamApiClient/SteamApiClientInterface.php index 45193da4..32068457 100644 --- a/src/Service/Steam/SteamApiClientInterface.php +++ b/src/Service/SteamApiClient/SteamApiClientInterface.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace App\Service\Steam; +namespace App\Service\SteamApiClient; -use App\Service\Steam\Dto\AppInfoDto; -use App\Service\Steam\Dto\WorkshopItemInfoDto; +use App\Service\SteamApiClient\Dto\AppInfoDto; +use App\Service\SteamApiClient\Dto\WorkshopItemInfoDto; interface SteamApiClientInterface { diff --git a/src/Service/SteamApiClient/Test/SteamApiClientMockResponseFactory.php b/src/Service/SteamApiClient/Test/SteamApiClientMockResponseFactory.php new file mode 100644 index 00000000..51ac84bd --- /dev/null +++ b/src/Service/SteamApiClient/Test/SteamApiClientMockResponseFactory.php @@ -0,0 +1,95 @@ + $this->getGetPublishedFileDetailsResponse($method, $url, $options), + 'GET' === $method && str_starts_with($url, 'https://store.steampowered.com/api/appdetails') => $this->getStoreResponse($method, $url, $options), + default => throw new \InvalidArgumentException('Unsupported request provided') + }; + } + + private function getGetPublishedFileDetailsResponse(string $method, string $url, array $options = []): MockResponse + { + $params = $this->parseFormDataParameters($options); + $publishedFileIds = $params['publishedfileids[0]']; + $path = sprintf('%s/data/GetPublishedFileDetails/%s.json', __DIR__, $publishedFileIds); + $json = @file_get_contents($path); + if (!$json) { + return $this->createPublishedFileDetailsNotFoundResponse($publishedFileIds); + } + + return $this->createJsonResponse($json); + } + + private function createPublishedFileDetailsNotFoundResponse(string $publishedFileIds): MockResponse + { + return $this->createJsonResponse([ + 'response' => [ + 'result' => 1, + 'resultcount' => 1, + 'publishedfiledetails' => [ + [ + 'publishedfileid' => $publishedFileIds, + 'result' => 1, + ], + ], + ], + ]); + } + + private function getStoreResponse(string $method, string $url, array $options = []): MockResponse + { + $appId = $options['query']['appids']; + $path = sprintf('%s/data/appdetails/%s.json', __DIR__, $appId); + $json = @file_get_contents($path); + if (!$json) { + return $this->createAppDetailsNotFoundResponse($appId); + } + + return $this->createJsonResponse($json); + } + + private function createAppDetailsNotFoundResponse(int $appId): MockResponse + { + return $this->createJsonResponse([ + $appId => [ + 'success' => false, + ], + ]); + } + + private function parseFormDataParameters(array $options): array + { + $params = []; + $formDataParams = explode('&', urldecode($options['body'])); + foreach ($formDataParams as $formDataParam) { + [$paramName, $paramValue] = explode('=', $formDataParam); + $params[$paramName] = $paramValue; + } + + return $params; + } + + private function createJsonResponse(array|string $json): MockResponse + { + if (\is_array($json)) { + $json = json_encode($json, JSON_THROW_ON_ERROR); + } + + return new MockResponse($json, [ + 'response_headers' => [ + 'content-type' => 'application/json', + ], + ]); + } +} diff --git a/src/Service/SteamApiClient/Test/data/GetPublishedFileDetails/1934142795.json b/src/Service/SteamApiClient/Test/data/GetPublishedFileDetails/1934142795.json new file mode 100644 index 00000000..ecd75fb9 --- /dev/null +++ b/src/Service/SteamApiClient/Test/data/GetPublishedFileDetails/1934142795.json @@ -0,0 +1,44 @@ +{ + "response": { + "result": 1, + "resultcount": 1, + "publishedfiledetails": [ + { + "publishedfileid": "1934142795", + "result": 1, + "creator": "76561199002669156", + "creator_app_id": 107410, + "consumer_app_id": 107410, + "filename": "", + "file_size": 30551990, + "file_url": "", + "hcontent_file": "5032060125057666325", + "preview_url": "https://steamuserimages-a.akamaihd.net/ugc/770609890915323775/A25459A5CA3CCDA214F4B5E1D8537D125E4739AD/", + "hcontent_preview": "770609890915323775", + "title": "ArmaForces - Mods", + "description": "[b]ArmaForces Mods[/b] is a collaborative effort by the members of [url=https://armaforces.com]ArmaForces[/url], polish Arma 3 community.\r\n\r\nMain purpose of this addon is to bend and adjust Arma 3 game features to the Group gameplay needs and style.\r\n\r\n\r\nhttps://github.com/ArmaForces/Mods", + "time_created": 1576074419, + "time_updated": 1696695976, + "visibility": 0, + "banned": 0, + "ban_reason": "", + "subscriptions": 360, + "favorited": 8, + "lifetime_subscriptions": 728, + "lifetime_favorited": 9, + "views": 894, + "tags": [ + { + "tag": "Mod" + }, + { + "tag": "Mechanics" + }, + { + "tag": "Editor Extension" + } + ] + } + ] + } +} diff --git a/src/Service/SteamApiClient/Test/data/appdetails/1227700.json b/src/Service/SteamApiClient/Test/data/appdetails/1227700.json new file mode 100644 index 00000000..f68d14b3 --- /dev/null +++ b/src/Service/SteamApiClient/Test/data/appdetails/1227700.json @@ -0,0 +1,433 @@ +{ + "1227700": { + "success": true, + "data": { + "type": "dlc", + "name": "Arma 3 Creator DLC: S.O.G. Prairie Fire", + "steam_appid": 1227700, + "required_age": 0, + "is_free": false, + "detailed_description": "

ARMA 3 CREATOR DLC


Purchase this DLC to support your favorite third-party developer and enjoy some of their best work yet. The Arma 3 Creator DLC program enables selected outside developers to publish original new content for Arma 3 as commercial DLC on Steam. The proceeds of Arma 3 Creator DLC: S.O.G. Prairie Fire are shared between Savage Game Design (developer), Bohemia Interactive (publisher), and Valve (digital distributor).


About the Game

Get ready to experience the brutal intensity of the Vietnam War on a monumental scale. Developed with the help of US veterans and Vietnamese advisors, S.O.G. Prairie Fire immerses you deep within enemy territory as a member of covert special ops unit MACV-SOG and delivers an Arma 3 sandbox experience you won’t forget.

Charge into battle with a wide range of historically accurate weapons and vehicles. Explore the steamy jungles and sprawling landscapes of Vietnam, Laos, and Cambodia. Run recon missions in a thrilling new co-op campaign and wage all-out war in new multiplayer and singleplayer scenarios.

Featuring the authentic combat, full-spectrum battlefield, and powerful scenario editor Arma 3 is renowned for, players can now experience the full scope of the Vietnam War on their own, with friends, or with one of the thousands of Arma community groups located around the world.

HOW TO LAUNCH


Arma 3 Creator DLC: S.O.G. Prairie Fire is optional to install and load. To play Arma 3 with this DLC enabled, please visit the DLC section in the Arma 3 Launcher, make sure S.O.G. Prairie Fire is owned and loaded, then launch the game by clicking the PLAY button.

KEY FEATURES



Cam Lao Nam - 300 km2 terrain

This unique new terrain enables players to design and run missions throughout all phases and locations of the war.


Complete with hand-painted billboards and posters, new buildings, trees, and objects, and over a thousand terrain assets, Cam Lao Nam provides an unforgettable sandbox for all your Arma adventures.

The 1.2 update adds exciting updates to the Cam Lao Nam terrain - the US Embassy in Saigon and the train station and new city buildings in Hanoi - each recreated from period photographs and thoroughly detailed to add more immersion to urban fighting.

Khe Sanh - 225km2 terrain

This unique new terrain enables players to design and run missions around Quang Tri Province, including some crucially contested locations of the war.


Featuring 2.7 million trees, buildings and objects from S.O.G. Prairie Fire Creator DLC, this large map is partly topographical and partly designed for gameplay. It features realistic scenery for Vietnam War fighting in Arma 3 with towering hills and deep valleys surrounding the Khe Sanh Combat Base.

The Bra - 25 km2 terrain

Welcome to The Bra, Laos.

This unique new terrain, covering 25 km2, enables players to design and run missions around an infamous section of the Ho Chi Minh Trail in Laos, nicknamed “The Bra” by MACV SOG units, due to the shape of the road as viewed from the air.


Featuring trees, buildings, and objects from the S.O.G. Prairie Fire Creator DLC, this new map is partly topographical and partly designed for gameplay. It provides a realistic recreation of a major MACV SOG target area in Laos, with detailed micro-terrain for intense close-quarters battle, made possible by the smaller map size.

13 New Factions, 85 New Weapons, New Uniforms & Gear

S.O.G. Prairie Fire offers 85 unique weapons with detailed animations, realistic sounds, melee features, and a diverse range of weapon accessories. There are 63 deadly grenades, traps, and other special items; 65 detailed uniforms; 69 vests; 43 backpacks; 20 accessories and 69 headgear items, all with numerous variations.


Each item was painstakingly designed with five years of oversight and advice from US Special Forces veterans who contributed their vast knowledge and private collections to help deliver the most realistic recreation of equipment possible.

46 New Vehicles & 43 Static Weapons

S.O.G. Prairie Fire features 13 asymmetric factions using vehicles to wage war in the jungles, mountains, cities, rivers, and islands of Vietnam, Cambodia and Laos.

", + "about_the_game": "Get ready to experience the brutal intensity of the Vietnam War on a monumental scale. Developed with the help of US veterans and Vietnamese advisors, S.O.G. Prairie Fire immerses you deep within enemy territory as a member of covert special ops unit MACV-SOG and delivers an Arma 3 sandbox experience you won’t forget.

Charge into battle with a wide range of historically accurate weapons and vehicles. Explore the steamy jungles and sprawling landscapes of Vietnam, Laos, and Cambodia. Run recon missions in a thrilling new co-op campaign and wage all-out war in new multiplayer and singleplayer scenarios.

Featuring the authentic combat, full-spectrum battlefield, and powerful scenario editor Arma 3 is renowned for, players can now experience the full scope of the Vietnam War on their own, with friends, or with one of the thousands of Arma community groups located around the world.

HOW TO LAUNCH


Arma 3 Creator DLC: S.O.G. Prairie Fire is optional to install and load. To play Arma 3 with this DLC enabled, please visit the DLC section in the Arma 3 Launcher, make sure S.O.G. Prairie Fire is owned and loaded, then launch the game by clicking the PLAY button.

KEY FEATURES



Cam Lao Nam - 300 km2 terrain

This unique new terrain enables players to design and run missions throughout all phases and locations of the war.


Complete with hand-painted billboards and posters, new buildings, trees, and objects, and over a thousand terrain assets, Cam Lao Nam provides an unforgettable sandbox for all your Arma adventures.

The 1.2 update adds exciting updates to the Cam Lao Nam terrain - the US Embassy in Saigon and the train station and new city buildings in Hanoi - each recreated from period photographs and thoroughly detailed to add more immersion to urban fighting.

Khe Sanh - 225km2 terrain

This unique new terrain enables players to design and run missions around Quang Tri Province, including some crucially contested locations of the war.


Featuring 2.7 million trees, buildings and objects from S.O.G. Prairie Fire Creator DLC, this large map is partly topographical and partly designed for gameplay. It features realistic scenery for Vietnam War fighting in Arma 3 with towering hills and deep valleys surrounding the Khe Sanh Combat Base.

The Bra - 25 km2 terrain

Welcome to The Bra, Laos.

This unique new terrain, covering 25 km2, enables players to design and run missions around an infamous section of the Ho Chi Minh Trail in Laos, nicknamed “The Bra” by MACV SOG units, due to the shape of the road as viewed from the air.


Featuring trees, buildings, and objects from the S.O.G. Prairie Fire Creator DLC, this new map is partly topographical and partly designed for gameplay. It provides a realistic recreation of a major MACV SOG target area in Laos, with detailed micro-terrain for intense close-quarters battle, made possible by the smaller map size.

13 New Factions, 85 New Weapons, New Uniforms & Gear

S.O.G. Prairie Fire offers 85 unique weapons with detailed animations, realistic sounds, melee features, and a diverse range of weapon accessories. There are 63 deadly grenades, traps, and other special items; 65 detailed uniforms; 69 vests; 43 backpacks; 20 accessories and 69 headgear items, all with numerous variations.


Each item was painstakingly designed with five years of oversight and advice from US Special Forces veterans who contributed their vast knowledge and private collections to help deliver the most realistic recreation of equipment possible.

46 New Vehicles & 43 Static Weapons

S.O.G. Prairie Fire features 13 asymmetric factions using vehicles to wage war in the jungles, mountains, cities, rivers, and islands of Vietnam, Cambodia and Laos.

", + "short_description": "Experience the intensity of the Vietnam War on a monumental scale. Featuring two vast terrains, a new co-op campaign, single/multiplayer scenarios, and dozens of weapons and vehicles, players can quell uprisings, run recon missions, and wage war in a historic take on Arma 3’s military sandbox.", + "fullgame": { + "appid": "107410", + "name": "Arma 3" + }, + "supported_languages": "English*, French, Italian, German, Spanish - Spain, Portuguese - Brazil, Russian, Simplified Chinese
*languages with full audio support", + "header_image": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/header.jpg?t=1687260796", + "capsule_image": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/capsule_231x87.jpg?t=1687260796", + "capsule_imagev5": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/capsule_184x69.jpg?t=1687260796", + "website": "https://sogpf.com/", + "pc_requirements": { + "minimum": "Minimum:
", + "recommended": "Recommended:
" + }, + "mac_requirements": { + "minimum": "Minimum:
", + "recommended": "Recommended:
" + }, + "linux_requirements": [], + "legal_notice": "Arma 3 supports the BattlEye anti-cheat engine. Most server admins choose to enable it on their servers, so please refrain from cheats and hacks or you may receive a global ban. BattlEye global bans are shared with DayZ and Arma 2: Operation Arrowhead.", + "developers": [ + "Savage Game Design" + ], + "publishers": [ + "Bohemia Interactive" + ], + "price_overview": { + "currency": "PLN", + "initial": 7999, + "final": 7999, + "discount_percent": 0, + "initial_formatted": "", + "final_formatted": "79,99zł" + }, + "packages": [ + 425631 + ], + "package_groups": [ + { + "name": "default", + "title": "Buy Arma 3 Creator DLC: S.O.G. Prairie Fire", + "description": "", + "selection_text": "Select a purchase option", + "save_text": "", + "display_type": 0, + "is_recurring_subscription": "false", + "subs": [ + { + "packageid": 425631, + "percent_savings_text": " ", + "percent_savings": 0, + "option_text": "Arma 3 Creator DLC: S.O.G. Prairie Fire - 79,99zł", + "option_description": "", + "can_get_free_license": "0", + "is_free_license": false, + "price_in_cents_with_discount": 7999 + } + ] + } + ], + "platforms": { + "windows": true, + "mac": true, + "linux": false + }, + "categories": [ + { + "id": 2, + "description": "Single-player" + }, + { + "id": 1, + "description": "Multi-player" + }, + { + "id": 49, + "description": "PvP" + }, + { + "id": 36, + "description": "Online PvP" + }, + { + "id": 47, + "description": "LAN PvP" + }, + { + "id": 9, + "description": "Co-op" + }, + { + "id": 38, + "description": "Online Co-op" + }, + { + "id": 48, + "description": "LAN Co-op" + }, + { + "id": 21, + "description": "Downloadable Content" + }, + { + "id": 30, + "description": "Steam Workshop" + }, + { + "id": 18, + "description": "Partial Controller Support" + }, + { + "id": 17, + "description": "Includes level editor" + } + ], + "genres": [ + { + "id": "1", + "description": "Action" + }, + { + "id": "28", + "description": "Simulation" + }, + { + "id": "2", + "description": "Strategy" + } + ], + "screenshots": [ + { + "id": 0, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_955bcff3c16f61754e3d631b509148fefe79b8ab.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_955bcff3c16f61754e3d631b509148fefe79b8ab.1920x1080.jpg?t=1687260796" + }, + { + "id": 1, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_671d94bda139431a064d48028bcd8c556c24064f.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_671d94bda139431a064d48028bcd8c556c24064f.1920x1080.jpg?t=1687260796" + }, + { + "id": 2, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_b98c9aa574614a4b0fba1fba3a94650cbcd532ed.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_b98c9aa574614a4b0fba1fba3a94650cbcd532ed.1920x1080.jpg?t=1687260796" + }, + { + "id": 3, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_ec1ff2b57b7720d9d45d772d2a47c82b9817a9bf.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_ec1ff2b57b7720d9d45d772d2a47c82b9817a9bf.1920x1080.jpg?t=1687260796" + }, + { + "id": 4, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_404e64276183dee5033ac6d4b37e584b95c9a35a.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_404e64276183dee5033ac6d4b37e584b95c9a35a.1920x1080.jpg?t=1687260796" + }, + { + "id": 5, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_ddbf4a26966f873dba701bd6d377bf12c783569f.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_ddbf4a26966f873dba701bd6d377bf12c783569f.1920x1080.jpg?t=1687260796" + }, + { + "id": 6, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_5d5a4def026d51cfb99024b398e513eebf152589.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_5d5a4def026d51cfb99024b398e513eebf152589.1920x1080.jpg?t=1687260796" + }, + { + "id": 7, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2d5632cadae6bf949addd4a2c6e099fa470fb6a7.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2d5632cadae6bf949addd4a2c6e099fa470fb6a7.1920x1080.jpg?t=1687260796" + }, + { + "id": 8, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_3a068fa2624a2a78fcd2135ab553231d6807ac9d.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_3a068fa2624a2a78fcd2135ab553231d6807ac9d.1920x1080.jpg?t=1687260796" + }, + { + "id": 9, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_36bbe2d5d2c90c9fd02416c21b95e77098e24842.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_36bbe2d5d2c90c9fd02416c21b95e77098e24842.1920x1080.jpg?t=1687260796" + }, + { + "id": 10, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_ad36a69d83bbe2c8704446203ba18fcc0543ff69.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_ad36a69d83bbe2c8704446203ba18fcc0543ff69.1920x1080.jpg?t=1687260796" + }, + { + "id": 11, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_99972eea4a5f9708145bea800c5e9d22a46019d3.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_99972eea4a5f9708145bea800c5e9d22a46019d3.1920x1080.jpg?t=1687260796" + }, + { + "id": 12, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_a406900cae3f0447baf569a6d63f8f5f2028564f.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_a406900cae3f0447baf569a6d63f8f5f2028564f.1920x1080.jpg?t=1687260796" + }, + { + "id": 13, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_31d0cddc20d4e985cc5c4338500eb337630bfe50.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_31d0cddc20d4e985cc5c4338500eb337630bfe50.1920x1080.jpg?t=1687260796" + }, + { + "id": 14, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_10e47e92a8d665de5543eb9db2e3e5c255c9ae51.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_10e47e92a8d665de5543eb9db2e3e5c255c9ae51.1920x1080.jpg?t=1687260796" + }, + { + "id": 15, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_1deb786c0079442aac92b2ee150b5aeeeccba354.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_1deb786c0079442aac92b2ee150b5aeeeccba354.1920x1080.jpg?t=1687260796" + }, + { + "id": 16, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2b26e0f14431d5b2913b29c8705e864727fa4557.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2b26e0f14431d5b2913b29c8705e864727fa4557.1920x1080.jpg?t=1687260796" + }, + { + "id": 17, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_b8e8374ef57dd7b52f9167acacb24dba77254e65.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_b8e8374ef57dd7b52f9167acacb24dba77254e65.1920x1080.jpg?t=1687260796" + }, + { + "id": 18, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_fde6bb51ad627e739bd965f041c249dc5f8ef17f.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_fde6bb51ad627e739bd965f041c249dc5f8ef17f.1920x1080.jpg?t=1687260796" + }, + { + "id": 19, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_e032b3cdd8849a0ad4d6d37558a010049049a899.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_e032b3cdd8849a0ad4d6d37558a010049049a899.1920x1080.jpg?t=1687260796" + }, + { + "id": 20, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_e12c62b2e75cb5eb84b4a938a48b59d9834a6b72.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_e12c62b2e75cb5eb84b4a938a48b59d9834a6b72.1920x1080.jpg?t=1687260796" + }, + { + "id": 21, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_939526674f70b7dbb541630a98174b08cec88b56.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_939526674f70b7dbb541630a98174b08cec88b56.1920x1080.jpg?t=1687260796" + }, + { + "id": 22, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_a75ba17edb3e7503800835989bf6d4e428770877.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_a75ba17edb3e7503800835989bf6d4e428770877.1920x1080.jpg?t=1687260796" + }, + { + "id": 23, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_1935d0b763f3c951b9d8b8a3e8516f73c170264b.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_1935d0b763f3c951b9d8b8a3e8516f73c170264b.1920x1080.jpg?t=1687260796" + }, + { + "id": 24, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_79df69833fdc9d174c25880dd0da3cf82fef9b5d.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_79df69833fdc9d174c25880dd0da3cf82fef9b5d.1920x1080.jpg?t=1687260796" + }, + { + "id": 25, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_d02c8c4ad7ac504c65cacddefb000756ede0f237.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_d02c8c4ad7ac504c65cacddefb000756ede0f237.1920x1080.jpg?t=1687260796" + }, + { + "id": 26, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_25c038ba057f59bfdbecdf58c7216e2fd4449376.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_25c038ba057f59bfdbecdf58c7216e2fd4449376.1920x1080.jpg?t=1687260796" + }, + { + "id": 27, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_d4145ffac33111efaf9b9fe67ca00962eee0716c.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_d4145ffac33111efaf9b9fe67ca00962eee0716c.1920x1080.jpg?t=1687260796" + }, + { + "id": 28, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_70e7ab757bc8c4808686b7ed9568d1d5a89571a7.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_70e7ab757bc8c4808686b7ed9568d1d5a89571a7.1920x1080.jpg?t=1687260796" + }, + { + "id": 29, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_8a88dd38ce3254a777a29779af188a4a9c1914d5.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_8a88dd38ce3254a777a29779af188a4a9c1914d5.1920x1080.jpg?t=1687260796" + }, + { + "id": 30, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_cd75f07bef629792b893d4f9d49d3f1886b9605f.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_cd75f07bef629792b893d4f9d49d3f1886b9605f.1920x1080.jpg?t=1687260796" + }, + { + "id": 31, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2f9ee45d88dea200fe9b9de53646cb2154db84c5.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2f9ee45d88dea200fe9b9de53646cb2154db84c5.1920x1080.jpg?t=1687260796" + }, + { + "id": 32, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_58518e9840c92ab7722bac859e21864884fe1bef.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_58518e9840c92ab7722bac859e21864884fe1bef.1920x1080.jpg?t=1687260796" + }, + { + "id": 33, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_801ef6cde3f59c48d98b29ed75947b8ae8f293c9.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_801ef6cde3f59c48d98b29ed75947b8ae8f293c9.1920x1080.jpg?t=1687260796" + }, + { + "id": 34, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_9546cbe555b00a32834bfe4670ba6e24f031b374.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_9546cbe555b00a32834bfe4670ba6e24f031b374.1920x1080.jpg?t=1687260796" + }, + { + "id": 35, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_de2b853db90ac171b5530e4a9478ca8c0395aa1c.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_de2b853db90ac171b5530e4a9478ca8c0395aa1c.1920x1080.jpg?t=1687260796" + }, + { + "id": 36, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_3a97988a271262a9b6df066c1723fc949fc88be6.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_3a97988a271262a9b6df066c1723fc949fc88be6.1920x1080.jpg?t=1687260796" + }, + { + "id": 37, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2e2b094d486f377a83e29e6a01190b2076e92d6e.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_2e2b094d486f377a83e29e6a01190b2076e92d6e.1920x1080.jpg?t=1687260796" + }, + { + "id": 38, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_45c6a8b7d80eb1e00cbaf8227fc85bb9207a700f.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_45c6a8b7d80eb1e00cbaf8227fc85bb9207a700f.1920x1080.jpg?t=1687260796" + }, + { + "id": 39, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_203f02e088b0479d10e5d26bff55ea6e004c92ed.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_203f02e088b0479d10e5d26bff55ea6e004c92ed.1920x1080.jpg?t=1687260796" + }, + { + "id": 40, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_3f5c98facfdeaed930d4d5d2ebf4aa05c0662335.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_3f5c98facfdeaed930d4d5d2ebf4aa05c0662335.1920x1080.jpg?t=1687260796" + }, + { + "id": 41, + "path_thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_36dbbd42ea741b8b41c509652dad55e2e465e252.600x338.jpg?t=1687260796", + "path_full": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/ss_36dbbd42ea741b8b41c509652dad55e2e465e252.1920x1080.jpg?t=1687260796" + } + ], + "movies": [ + { + "id": 256951173, + "name": "SOG-PF 1.3 Trailer PEGI", + "thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/256951173/movie.293x165.jpg?t=1686662425", + "webm": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256951173/movie480_vp9.webm?t=1686662425", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256951173/movie_max_vp9.webm?t=1686662425" + }, + "mp4": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256951173/movie480.mp4?t=1686662425", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256951173/movie_max.mp4?t=1686662425" + }, + "highlight": true + }, + { + "id": 256833494, + "name": "SOG-PF Release Trailer PEGI Sub", + "thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/256833494/movie.293x165.jpg?t=1620302359", + "webm": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256833494/movie480_vp9.webm?t=1620302359", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256833494/movie_max_vp9.webm?t=1620302359" + }, + "mp4": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256833494/movie480.mp4?t=1620302359", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256833494/movie_max.mp4?t=1620302359" + }, + "highlight": true + }, + { + "id": 256853801, + "name": "SOG-PF 1.1 Trailer PEGI", + "thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/256853801/movie.293x165.jpg?t=1633008339", + "webm": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256853801/movie480_vp9.webm?t=1633008339", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256853801/movie_max_vp9.webm?t=1633008339" + }, + "mp4": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256853801/movie480.mp4?t=1633008339", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256853801/movie_max.mp4?t=1633008339" + }, + "highlight": true + }, + { + "id": 256895224, + "name": "SOG-PF 1.2 Trailer PEGI", + "thumbnail": "https://cdn.akamai.steamstatic.com/steam/apps/256895224/movie.293x165.jpg?t=1657631166", + "webm": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256895224/movie480_vp9.webm?t=1657631166", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256895224/movie_max_vp9.webm?t=1657631166" + }, + "mp4": { + "480": "http://cdn.akamai.steamstatic.com/steam/apps/256895224/movie480.mp4?t=1657631166", + "max": "http://cdn.akamai.steamstatic.com/steam/apps/256895224/movie_max.mp4?t=1657631166" + }, + "highlight": true + } + ], + "recommendations": { + "total": 1863 + }, + "release_date": { + "coming_soon": false, + "date": "6 May, 2021" + }, + "support_info": { + "url": "http://arma3.com/faq", + "email": "support@bohemia.net" + }, + "background": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/page_bg_generated_v6b.jpg?t=1687260796", + "background_raw": "https://cdn.akamai.steamstatic.com/steam/apps/1227700/page_bg_generated.jpg?t=1687260796", + "content_descriptors": { + "ids": [ + 2, + 5 + ], + "notes": "This Game may contain content not appropriate for all ages, or may not be appropriate for viewing at work: Frequent and Intense Violence, Bad Language, General Mature Content." + } + } + } +} diff --git a/src/Twig/SteamExtension.php b/src/Twig/SteamExtension.php index b93e5451..07034d58 100644 --- a/src/Twig/SteamExtension.php +++ b/src/Twig/SteamExtension.php @@ -4,7 +4,7 @@ namespace App\Twig; -use App\Service\Steam\Helper\SteamHelper; +use App\Service\SteamApiClient\Helper\SteamHelper; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; diff --git a/src/Validator/Dlc/SteamStoreArma3DlcUrlValidator.php b/src/Validator/Dlc/SteamStoreArma3DlcUrlValidator.php index 2b59c2ce..064aa217 100644 --- a/src/Validator/Dlc/SteamStoreArma3DlcUrlValidator.php +++ b/src/Validator/Dlc/SteamStoreArma3DlcUrlValidator.php @@ -5,10 +5,10 @@ namespace App\Validator\Dlc; use App\Form\Dlc\Dto\DlcFormDto; -use App\Service\Steam\Exception\AppNotFoundException; -use App\Service\Steam\Helper\Exception\InvalidAppUrlFormatException; -use App\Service\Steam\Helper\SteamHelper; -use App\Service\Steam\SteamApiClientInterface; +use App\Service\SteamApiClient\Exception\AppNotFoundException; +use App\Service\SteamApiClient\Helper\Exception\InvalidAppUrlFormatException; +use App\Service\SteamApiClient\Helper\SteamHelper; +use App\Service\SteamApiClient\SteamApiClientInterface; use App\Validator\AbstractValidator; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Validator\Constraint; diff --git a/src/Validator/Dlc/UniqueSteamStoreDlcValidator.php b/src/Validator/Dlc/UniqueSteamStoreDlcValidator.php index 8c00bba4..556a48eb 100644 --- a/src/Validator/Dlc/UniqueSteamStoreDlcValidator.php +++ b/src/Validator/Dlc/UniqueSteamStoreDlcValidator.php @@ -6,8 +6,8 @@ use App\Entity\Dlc\Dlc; use App\Form\Dlc\Dto\DlcFormDto; -use App\Service\Steam\Helper\Exception\InvalidAppUrlFormatException; -use App\Service\Steam\Helper\SteamHelper; +use App\Service\SteamApiClient\Helper\Exception\InvalidAppUrlFormatException; +use App\Service\SteamApiClient\Helper\SteamHelper; use App\Validator\AbstractValidator; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Exception\UnexpectedTypeException; diff --git a/src/Validator/Mod/SteamWorkshopArma3ModUrlValidator.php b/src/Validator/Mod/SteamWorkshopArma3ModUrlValidator.php index d6ef5870..b30d3b4e 100644 --- a/src/Validator/Mod/SteamWorkshopArma3ModUrlValidator.php +++ b/src/Validator/Mod/SteamWorkshopArma3ModUrlValidator.php @@ -5,10 +5,10 @@ namespace App\Validator\Mod; use App\Form\Mod\Dto\ModFormDto; -use App\Service\Steam\Exception\WorkshopItemNotFoundException; -use App\Service\Steam\Helper\Exception\InvalidWorkshopItemUrlFormatException; -use App\Service\Steam\Helper\SteamHelper; -use App\Service\Steam\SteamApiClientInterface; +use App\Service\SteamApiClient\Exception\WorkshopItemNotFoundException; +use App\Service\SteamApiClient\Helper\Exception\InvalidWorkshopItemUrlFormatException; +use App\Service\SteamApiClient\Helper\SteamHelper; +use App\Service\SteamApiClient\SteamApiClientInterface; use App\Validator\AbstractValidator; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Validator\Constraint; diff --git a/src/Validator/Mod/UniqueSteamWorkshopModValidator.php b/src/Validator/Mod/UniqueSteamWorkshopModValidator.php index 305cada1..3692ae9b 100644 --- a/src/Validator/Mod/UniqueSteamWorkshopModValidator.php +++ b/src/Validator/Mod/UniqueSteamWorkshopModValidator.php @@ -6,8 +6,8 @@ use App\Entity\Mod\SteamWorkshopMod; use App\Form\Mod\Dto\ModFormDto; -use App\Service\Steam\Helper\Exception\InvalidWorkshopItemUrlFormatException; -use App\Service\Steam\Helper\SteamHelper; +use App\Service\SteamApiClient\Helper\Exception\InvalidWorkshopItemUrlFormatException; +use App\Service\SteamApiClient\Helper\SteamHelper; use App\Validator\AbstractValidator; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Exception\UnexpectedTypeException; diff --git a/tests/integration/Service/Steam/SteamApiClientTest.php b/tests/integration/Service/Steam/SteamApiClientTest.php deleted file mode 100644 index 67cde5fc..00000000 --- a/tests/integration/Service/Steam/SteamApiClientTest.php +++ /dev/null @@ -1,34 +0,0 @@ -getWorkshopItemInfo($this::ITEM_ID); - - self::assertSame($this::ITEM_ID, $workshopItemInfoDto->getId()); - self::assertSame($this::ITEM_NAME, $workshopItemInfoDto->getName()); - self::assertSame($this::ITEM_GAME_ID, $workshopItemInfoDto->getGameId()); - } -} diff --git a/tests/integration/Service/SteamApiClient/SteamApiClientTest.php b/tests/integration/Service/SteamApiClient/SteamApiClientTest.php new file mode 100644 index 00000000..f60ba213 --- /dev/null +++ b/tests/integration/Service/SteamApiClient/SteamApiClientTest.php @@ -0,0 +1,83 @@ +steamApiClient = self::getContainer()->get(SteamApiClientInterface::class); + } + + /** + * @test + */ + public function getWorkshopItemInfo_existingItem_returnsItemDto(): void + { + $workshopItemInfoDto = $this->steamApiClient->getWorkshopItemInfo($this::ITEM_ID); + + self::assertSame($this::ITEM_ID, $workshopItemInfoDto->getId()); + self::assertSame($this::ITEM_NAME, $workshopItemInfoDto->getName()); + self::assertSame($this::ITEM_GAME_ID, $workshopItemInfoDto->getGameId()); + } + + /** + * @test + */ + public function getWorkshopItemInfo_nonExistingItem_throwsException(): void + { + $this->expectException(WorkshopItemNotFoundException::class); + $this->expectExceptionMessage(sprintf('No items found by item id "%s"!', 1)); + + $this->steamApiClient->getWorkshopItemInfo(1); + } + + /** + * @test + */ + public function getAppInfo_existingApp_returnsAppInfoDto(): void + { + $appInfoDto = $this->steamApiClient->getAppInfo($this::APP_ID); + + self::assertSame($this::APP_ID, $appInfoDto->getId()); + self::assertSame($this::APP_NAME, $appInfoDto->getName()); + self::assertSame($this::APP_TYPE, $appInfoDto->getType()); + self::assertSame($this::APP_GAME_ID, $appInfoDto->getGameId()); + } + + /** + * @test + */ + public function getAppInfo_nonExistingApp_throwsException(): void + { + $this->expectException(AppNotFoundException::class); + $this->expectExceptionMessage(sprintf('No apps found by app id "%s"!', 1)); + + $this->steamApiClient->getAppInfo(1); + } +} diff --git a/tests/unit/Service/Steam/SteamApiClientTest.php b/tests/unit/Service/Steam/SteamApiClientTest.php deleted file mode 100644 index cb4fa695..00000000 --- a/tests/unit/Service/Steam/SteamApiClientTest.php +++ /dev/null @@ -1,83 +0,0 @@ -mockResponsePayload(1, $this::ITEM_NAME, $this::ITEM_GAME_ID); - - /** @var HttpClientInterface $httpClient */ - $httpClient = $this->mockHttpClient($responsePayload); - $steamWorkshopClient = new SteamApiClient($httpClient); - $workshopItemInfoDto = $steamWorkshopClient->getWorkshopItemInfo($this::ITEM_ID); - - self::assertSame($this::ITEM_ID, $workshopItemInfoDto->getId()); - self::assertSame($this::ITEM_NAME, $workshopItemInfoDto->getName()); - self::assertSame($this::ITEM_GAME_ID, $workshopItemInfoDto->getGameId()); - } - - /** - * @test - */ - public function getWorkshopItemInfo_nonExistingItem_throwsException(): void - { - $responsePayload = $this->mockResponsePayload(0, $this::ITEM_NAME, $this::ITEM_GAME_ID); - - /** @var HttpClientInterface $httpClient */ - $httpClient = $this->mockHttpClient($responsePayload); - $steamWorkshopClient = new SteamApiClient($httpClient); - - $this->expectException(WorkshopItemNotFoundException::class); - $this->expectExceptionMessage(sprintf('No items found by item id "%s"!', $this::ITEM_ID)); - - $steamWorkshopClient->getWorkshopItemInfo($this::ITEM_ID); - } - - private function mockResponsePayload(int $resultCount, string $itemName, int $itemGameId): array - { - return [ - 'response' => [ - 'resultcount' => $resultCount, - 'publishedfiledetails' => [ - [ - 'title' => $itemName, - 'creator_app_id' => $itemGameId, - ], - ], - ], - ]; - } - - private function mockHttpClient(array $responsePayload): MockObject - { - $response = $this->createMock(ResponseInterface::class); - $response->method('toArray')->willReturn($responsePayload); - - $httpClient = $this->createMock(HttpClientInterface::class); - $httpClient->method('request')->willReturn($response); - - return $httpClient; - } -} diff --git a/tests/unit/Service/Steam/Helper/SteamHelperTest.php b/tests/unit/Service/SteamApiClient/Helper/SteamHelperTest.php similarity index 88% rename from tests/unit/Service/Steam/Helper/SteamHelperTest.php rename to tests/unit/Service/SteamApiClient/Helper/SteamHelperTest.php index 0dd0292a..29a1a04e 100644 --- a/tests/unit/Service/Steam/Helper/SteamHelperTest.php +++ b/tests/unit/Service/SteamApiClient/Helper/SteamHelperTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace App\Tests\Unit\Service\Steam\Helper; +namespace App\Tests\Unit\Service\SteamApiClient\Helper; -use App\Service\Steam\Helper\Exception\InvalidWorkshopItemUrlFormatException; -use App\Service\Steam\Helper\SteamHelper; +use App\Service\SteamApiClient\Helper\Exception\InvalidWorkshopItemUrlFormatException; +use App\Service\SteamApiClient\Helper\SteamHelper; use PHPUnit\Framework\TestCase; /** * @internal - * @covers \App\Service\Steam\Helper\SteamHelper + * @covers \App\Service\SteamApiClient\Helper\SteamHelper */ final class SteamHelperTest extends TestCase {