From 1f1af23fdc3abcf4193e9d5b34d8e5cb81afb564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pimpa=CC=83o?= Date: Mon, 20 Nov 2023 12:26:44 +0000 Subject: [PATCH 1/6] chore: some code cleanup --- composer.json | 2 +- src/Endpoint/Util/TimezoneTrait.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7889ea1..03d6ed1 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "programmatordev/sportmonksfootball-php-api", "description": "SportMonksFootball PHP library that provides convenient access to the SportMonks Football API", "type": "library", - "keywords": ["SportMonksFootball", "SportMonks", "Football", "API", "PHP", "PHP8", "SDK", "PSR-18", "PSR-17", "PSR-6", "PSR-3"], + "keywords": ["sportmonks", "football", "api", "sportmonks-football-api", "football-api", "php", "php8", "psr-18", "psr-17", "psr-6", "psr-3"], "license": "MIT", "authors": [ { diff --git a/src/Endpoint/Util/TimezoneTrait.php b/src/Endpoint/Util/TimezoneTrait.php index 80233c3..4d02fa0 100644 --- a/src/Endpoint/Util/TimezoneTrait.php +++ b/src/Endpoint/Util/TimezoneTrait.php @@ -5,7 +5,6 @@ use ProgrammatorDev\YetAnotherPhpValidator\Exception\ValidationException; use ProgrammatorDev\YetAnotherPhpValidator\Validator; -// TODO create tests for trait upon implementation of an endpoint that makes use of it trait TimezoneTrait { /** From 5cb1728dfdac6153b3992eb008eb0e40c1662065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pimpa=CC=83o?= Date: Mon, 20 Nov 2023 13:14:54 +0000 Subject: [PATCH 2/6] feat: added Timezone endpoint --- src/Endpoint/TimezoneEndpoint.php | 26 ++++++++++++++++++++++ src/Entity/Response/TimezoneCollection.php | 21 +++++++++++++++++ src/SportMonksFootball.php | 6 +++++ 3 files changed, 53 insertions(+) create mode 100644 src/Endpoint/TimezoneEndpoint.php create mode 100644 src/Entity/Response/TimezoneCollection.php diff --git a/src/Endpoint/TimezoneEndpoint.php b/src/Endpoint/TimezoneEndpoint.php new file mode 100644 index 0000000..ba14f9b --- /dev/null +++ b/src/Endpoint/TimezoneEndpoint.php @@ -0,0 +1,26 @@ +sendRequest( + method: 'GET', + path: '/v3/core/timezones' + ); + + return new TimezoneCollection($response); + } +} \ No newline at end of file diff --git a/src/Entity/Response/TimezoneCollection.php b/src/Entity/Response/TimezoneCollection.php new file mode 100644 index 0000000..4983bfe --- /dev/null +++ b/src/Entity/Response/TimezoneCollection.php @@ -0,0 +1,21 @@ +data = $response['data']; + } + + public function getData(): array + { + return $this->data; + } +} \ No newline at end of file diff --git a/src/SportMonksFootball.php b/src/SportMonksFootball.php index ca46a74..94128a5 100644 --- a/src/SportMonksFootball.php +++ b/src/SportMonksFootball.php @@ -27,6 +27,7 @@ use ProgrammatorDev\SportMonksFootball\Endpoint\StatisticEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TeamEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TeamSquadEndpoint; +use ProgrammatorDev\SportMonksFootball\Endpoint\TimezoneEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TopscorerEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TransferEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TvStationEndpoint; @@ -167,6 +168,11 @@ public function teamSquads(): TeamSquadEndpoint return new TeamSquadEndpoint($this); } + public function timezones(): TimezoneEndpoint + { + return new TimezoneEndpoint($this); + } + public function topscorers(): TopscorerEndpoint { return new TopscorerEndpoint($this); From 66462e4d965d6d38734fac9d6241ff0775da4695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pimpa=CC=83o?= Date: Mon, 20 Nov 2023 13:40:47 +0000 Subject: [PATCH 3/6] chore: refactored tests --- src/Test/MockResponse.php | 2 + tests/BookmakerEndpointTest.php | 16 ++----- tests/CityEndpointTest.php | 12 ++--- tests/CoachEndpointTest.php | 20 ++------ tests/CommentaryEndpointTest.php | 8 +--- tests/ContinentEndpointTest.php | 8 +--- tests/CountryEndpointTest.php | 12 ++--- tests/FilterEndpointTest.php | 4 +- tests/FixtureEndpointTest.php | 48 +++++-------------- tests/LeagueEndpointTest.php | 32 ++++--------- tests/LivescoreEndpointTest.php | 12 ++--- tests/MarketEndpointTest.php | 12 ++--- tests/PlayerEndpointTest.php | 20 ++------ tests/PreMatchOddEndpointTest.php | 20 ++------ tests/RefereeEndpointTest.php | 20 ++------ tests/RegionEndpointTest.php | 12 ++--- tests/RivalEndpointTest.php | 8 +--- tests/RoundEndpointTest.php | 16 ++----- tests/ScheduleEndpointTest.php | 12 ++--- tests/SeasonEndpointTest.php | 16 ++----- tests/StageEndpointTest.php | 16 ++----- tests/StandingEndpointTest.php | 5 -- tests/StateEndpointTest.php | 8 +--- tests/StatisticEndpointTest.php | 6 --- tests/TeamEndpointTest.php | 17 ++----- tests/TeamSquadEndpointTest.php | 8 +--- tests/TopscorerEndpointTest.php | 8 +--- tests/TransferEndpointTest.php | 24 +++------- tests/TvStationEndpointTest.php | 12 ++--- tests/TypeEndpointTest.php | 3 -- .../TestEndpointCollectionResponseTrait.php | 8 +--- tests/Util/TestEndpointItemResponseTrait.php | 6 +-- tests/VenueEndpointTest.php | 16 ++----- 33 files changed, 110 insertions(+), 337 deletions(-) diff --git a/src/Test/MockResponse.php b/src/Test/MockResponse.php index 239b9df..9d8144e 100644 --- a/src/Test/MockResponse.php +++ b/src/Test/MockResponse.php @@ -74,6 +74,8 @@ class MockResponse public const TEAM_SQUAD_COLLECTION_DATA = '[{"id":741301,"transfer_id":233006,"player_id":8056287,"team_id":53,"position_id":25,"detailed_position_id":148,"start":"2023-07-26","end":"2028-05-31","captain":false,"jersey_number":17},{"id":762227,"transfer_id":234932,"player_id":3533334,"team_id":53,"position_id":25,"detailed_position_id":148,"start":"2023-08-16","end":"2028-05-31","captain":false,"jersey_number":4}]'; + public const TIMEZONE_COLLECTION_DATA = '["Africa\/Abidjan","Africa\/Accra","Africa\/Addis_Ababa"]'; + public const TOPSCORER_COLLECTION_DATA = '[{"id":1540882,"season_id":19735,"player_id":37305554,"type_id":83,"position":1,"total":3,"participant_id":246},{"id":1540879,"season_id":19735,"player_id":1494374,"type_id":83,"position":2,"total":3,"participant_id":314}]'; public const TRANSFER_ITEM_DATA = '{"id":1,"sport_id":1,"player_id":35659846,"type_id":219,"from_team_id":148048,"to_team_id":3736,"position_id":25,"detailed_position_id":154,"date":"2021-12-27","career_ended":false,"completed":true,"amount":909000}'; diff --git a/tests/BookmakerEndpointTest.php b/tests/BookmakerEndpointTest.php index 9b6e450..1b50398 100644 --- a/tests/BookmakerEndpointTest.php +++ b/tests/BookmakerEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::BOOKMAKER_ITEM_DATA, 'bookmakers', 'getById', - [1], - Bookmaker::class, - 'assertResponse' + [1] ]; } @@ -33,25 +31,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::BOOKMAKER_COLLECTION_DATA, 'bookmakers', 'getAll', - [], - Bookmaker::class, - 'assertResponse' + [] ]; yield 'get all by fixture id' => [ MockResponse::BOOKMAKER_COLLECTION_DATA, 'bookmakers', 'getAllByFixtureId', - [1], - Bookmaker::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::BOOKMAKER_COLLECTION_DATA, 'bookmakers', 'getAllBySearchQuery', - ['test'], - Bookmaker::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/CityEndpointTest.php b/tests/CityEndpointTest.php index a7d8a25..a3a253e 100644 --- a/tests/CityEndpointTest.php +++ b/tests/CityEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::CITY_ITEM_DATA, 'cities', 'getById', - [1], - City::class, - 'assertResponse' + [1] ]; } @@ -33,17 +31,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::CITY_COLLECTION_DATA, 'cities', 'getAll', - [], - City::class, - 'assertResponse' + [] ]; yield 'get all by search query' => [ MockResponse::CITY_COLLECTION_DATA, 'cities', 'getAllBySearchQuery', - ['test'], - City::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/CoachEndpointTest.php b/tests/CoachEndpointTest.php index e63d9a1..4ae915f 100644 --- a/tests/CoachEndpointTest.php +++ b/tests/CoachEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::COACH_ITEM_DATA, 'coaches', 'getById', - [1], - Coach::class, - 'assertResponse' + [1] ]; } @@ -33,33 +31,25 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::COACH_COLLECTION_DATA, 'coaches', 'getAll', - [], - Coach::class, - 'assertResponse' + [] ]; yield 'get all by country id' => [ MockResponse::COACH_COLLECTION_DATA, 'coaches', 'getAllByCountryId', - [1], - Coach::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::COACH_COLLECTION_DATA, 'coaches', 'getAllBySearchQuery', - ['test'], - Coach::class, - 'assertResponse' + ['test'] ]; yield 'get all last updated' => [ MockResponse::COACH_COLLECTION_DATA, 'coaches', 'getAllLastUpdated', - [], - Coach::class, - 'assertResponse' + [] ]; } diff --git a/tests/CommentaryEndpointTest.php b/tests/CommentaryEndpointTest.php index 1160038..910c485 100644 --- a/tests/CommentaryEndpointTest.php +++ b/tests/CommentaryEndpointTest.php @@ -17,17 +17,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::COMMENTARY_COLLECTION_DATA, 'commentaries', 'getAll', - [], - Commentary::class, - 'assertResponse' + [] ]; yield 'get all by fixture id' => [ MockResponse::COMMENTARY_COLLECTION_DATA, 'commentaries', 'getAllByFixtureId', - [1], - Commentary::class, - 'assertResponse' + [1] ]; } diff --git a/tests/ContinentEndpointTest.php b/tests/ContinentEndpointTest.php index a1ef82f..ffd7cff 100644 --- a/tests/ContinentEndpointTest.php +++ b/tests/ContinentEndpointTest.php @@ -19,9 +19,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::CONTINENT_ITEM_DATA, 'continents', 'getById', - [1], - Continent::class, - 'assertResponse' + [1] ]; } @@ -31,9 +29,7 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::CONTINENT_COLLECTION_DATA, 'continents', 'getAll', - [], - Continent::class, - 'assertResponse' + [] ]; } diff --git a/tests/CountryEndpointTest.php b/tests/CountryEndpointTest.php index da4d999..bd8e0cc 100644 --- a/tests/CountryEndpointTest.php +++ b/tests/CountryEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::COUNTRY_ITEM_DATA, 'countries', 'getById', - [1], - Country::class, - 'assertResponse' + [1] ]; } @@ -33,17 +31,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::COUNTRY_COLLECTION_DATA, 'countries', 'getAll', - [], - Country::class, - 'assertResponse' + [] ]; yield 'get all by search query' => [ MockResponse::COUNTRY_COLLECTION_DATA, 'countries', 'getAllBySearchQuery', - ['test'], - Country::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/FilterEndpointTest.php b/tests/FilterEndpointTest.php index 2e93799..a0a6504 100644 --- a/tests/FilterEndpointTest.php +++ b/tests/FilterEndpointTest.php @@ -15,9 +15,7 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::FILTER_ENTITY_COLLECTION_DATA, 'filters', 'getAllByEntity', - [], - FilterEntity::class, - 'assertResponse' + [] ]; } diff --git a/tests/FixtureEndpointTest.php b/tests/FixtureEndpointTest.php index c18dc95..31ec65d 100644 --- a/tests/FixtureEndpointTest.php +++ b/tests/FixtureEndpointTest.php @@ -23,9 +23,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::FIXTURE_ITEM_DATA, 'fixtures', 'getById', - [1], - Fixture::class, - 'assertResponse' + [1] ]; } @@ -35,89 +33,67 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAll', - [], - Fixture::class, - 'assertResponse' + [] ]; yield 'get all by multiple ids' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllByMultipleIds', - [[1, 2]], - Fixture::class, - 'assertResponse' + [[1, 2]] ]; yield 'get all by date' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllByDate', - [new \DateTime('today')], - Fixture::class, - 'assertResponse' + [new \DateTime('today')] ]; yield 'get all by date range' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllByDateRange', - [new \DateTime('today'), new \DateTime('tomorrow')], - Fixture::class, - 'assertResponse' + [new \DateTime('today'), new \DateTime('tomorrow')] ]; yield 'get all by team id and date range' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllByTeamIdAndDateRange', - [1, new \DateTime('today'), new \DateTime('tomorrow')], - Fixture::class, - 'assertResponse' + [1, new \DateTime('today'), new \DateTime('tomorrow')] ]; yield 'get all by head to head' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllByHeadToHead', - [1, 2], - Fixture::class, - 'assertResponse' + [1, 2] ]; yield 'get all by search query' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllBySearchQuery', - ['test'], - Fixture::class, - 'assertResponse' + ['test'] ]; yield 'get all upcoming by market id' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllUpcomingByMarketId', - [1], - Fixture::class, - 'assertResponse' + [1] ]; yield 'get all upcoming by tv station id' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllUpcomingByTvStationId', - [1], - Fixture::class, - 'assertResponse' + [1] ]; yield 'get all past by tv station id' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllPastByTvStationId', - [1], - Fixture::class, - 'assertResponse' + [1] ]; yield 'get all last updated' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'fixtures', 'getAllLastUpdated', - [], - Fixture::class, - 'assertResponse' + [] ]; } diff --git a/tests/LeagueEndpointTest.php b/tests/LeagueEndpointTest.php index 29d3633..5952600 100644 --- a/tests/LeagueEndpointTest.php +++ b/tests/LeagueEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::LEAGUE_ITEM_DATA, 'leagues', 'getById', - [1], - League::class, - 'assertResponse' + [1] ]; } @@ -33,57 +31,43 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAll', - [], - League::class, - 'assertResponse' + [] ]; yield 'get all live' => [ MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAllLive', - [], - League::class, - 'assertResponse' + [] ]; yield 'get all by fixture date' => [ MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAllByFixtureDate', - [new \DateTime('today')], - League::class, - 'assertResponse' + [new \DateTime('today')] ]; yield 'get all by country id' => [ MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAllByCountryId', - [1], - League::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAllBySearchQuery', - ['test'], - League::class, - 'assertResponse' + ['test'] ]; yield 'get all by team id' => [ MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAllByTeamId', - [1], - League::class, - 'assertResponse' + [1] ]; yield 'get all current by team id' => [ MockResponse::LEAGUE_COLLECTION_DATA, 'leagues', 'getAllCurrentByTeamId', - [1], - League::class, - 'assertResponse' + [1] ]; } diff --git a/tests/LivescoreEndpointTest.php b/tests/LivescoreEndpointTest.php index 5adfb05..fa7b13b 100644 --- a/tests/LivescoreEndpointTest.php +++ b/tests/LivescoreEndpointTest.php @@ -15,25 +15,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::FIXTURE_COLLECTION_DATA, 'livescores', 'getAll', - [], - Fixture::class, - 'assertResponse' + [] ]; yield 'get all inplay' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'livescores', 'getAllInplay', - [], - Fixture::class, - 'assertResponse' + [] ]; yield 'get all last updated' => [ MockResponse::FIXTURE_COLLECTION_DATA, 'livescores', 'getAllLastUpdated', - [], - Fixture::class, - 'assertResponse' + [] ]; } diff --git a/tests/MarketEndpointTest.php b/tests/MarketEndpointTest.php index ce611f3..3df53ba 100644 --- a/tests/MarketEndpointTest.php +++ b/tests/MarketEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::MARKET_ITEM_DATA, 'markets', 'getById', - [1], - Market::class, - 'assertResponse' + [1] ]; } @@ -33,17 +31,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::MARKET_COLLECTION_DATA, 'markets', 'getAll', - [], - Market::class, - 'assertResponse' + [] ]; yield 'get all by search query' => [ MockResponse::MARKET_COLLECTION_DATA, 'markets', 'getAllBySearchQuery', - ['test'], - Market::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/PlayerEndpointTest.php b/tests/PlayerEndpointTest.php index 425b34e..445c107 100644 --- a/tests/PlayerEndpointTest.php +++ b/tests/PlayerEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::PLAYER_ITEM_DATA, 'players', 'getById', - [1], - Player::class, - 'assertResponse' + [1] ]; } @@ -33,33 +31,25 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::PLAYER_COLLECTION_DATA, 'players', 'getAll', - [], - Player::class, - 'assertResponse' + [] ]; yield 'get all by country id' => [ MockResponse::PLAYER_COLLECTION_DATA, 'players', 'getAllByCountryId', - [1], - Player::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::PLAYER_COLLECTION_DATA, 'players', 'getAllBySearchQuery', - ['test'], - Player::class, - 'assertResponse' + ['test'] ]; yield 'get all last updated' => [ MockResponse::PLAYER_COLLECTION_DATA, 'players', 'getAllLastUpdated', - [], - Player::class, - 'assertResponse' + [] ]; } diff --git a/tests/PreMatchOddEndpointTest.php b/tests/PreMatchOddEndpointTest.php index ccaf67a..351af38 100644 --- a/tests/PreMatchOddEndpointTest.php +++ b/tests/PreMatchOddEndpointTest.php @@ -17,41 +17,31 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::ODD_COLLECTION_DATA, 'preMatchOdds', 'getAll', - [], - Odd::class, - 'assertResponse' + [] ]; yield 'get all by fixture id' => [ MockResponse::ODD_COLLECTION_DATA, 'preMatchOdds', 'getAllByFixtureId', - [1], - Odd::class, - 'assertResponse' + [1] ]; yield 'get all by fixture id and bookmaker id' => [ MockResponse::ODD_COLLECTION_DATA, 'preMatchOdds', 'getAllByFixtureIdAndBookmakerId', - [1, 1], - Odd::class, - 'assertResponse' + [1, 1] ]; yield 'get all by fixture id and market id' => [ MockResponse::ODD_COLLECTION_DATA, 'preMatchOdds', 'getAllByFixtureIdAndMarketId', - [1, 1], - Odd::class, - 'assertResponse' + [1, 1] ]; yield 'get all last updated' => [ MockResponse::ODD_COLLECTION_DATA, 'preMatchOdds', 'getAllLastUpdated', - [], - Odd::class, - 'assertResponse' + [] ]; } diff --git a/tests/RefereeEndpointTest.php b/tests/RefereeEndpointTest.php index b85608b..59babc9 100644 --- a/tests/RefereeEndpointTest.php +++ b/tests/RefereeEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::REFEREE_ITEM_DATA, 'referees', 'getById', - [1], - Referee::class, - 'assertResponse' + [1] ]; } @@ -33,33 +31,25 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::REFEREE_COLLECTION_DATA, 'referees', 'getAll', - [], - Referee::class, - 'assertResponse' + [] ]; yield 'get all by country id' => [ MockResponse::REFEREE_COLLECTION_DATA, 'referees', 'getAllByCountryId', - [1], - Referee::class, - 'assertResponse' + [1] ]; yield 'get all by season id' => [ MockResponse::REFEREE_COLLECTION_DATA, 'referees', 'getAllBySeasonId', - [1], - Referee::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::REFEREE_COLLECTION_DATA, 'referees', 'getAllBySearchQuery', - ['test'], - Referee::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/RegionEndpointTest.php b/tests/RegionEndpointTest.php index 3bfa00d..823c757 100644 --- a/tests/RegionEndpointTest.php +++ b/tests/RegionEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::REGION_ITEM_DATA, 'regions', 'getById', - [1], - Region::class, - 'assertResponse' + [1] ]; } @@ -33,17 +31,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::REGION_COLLECTION_DATA, 'regions', 'getAll', - [], - Region::class, - 'assertResponse' + [] ]; yield 'get all by search query' => [ MockResponse::REGION_COLLECTION_DATA, 'regions', 'getAllBySearchQuery', - ['test'], - Region::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/RivalEndpointTest.php b/tests/RivalEndpointTest.php index 24d4d7f..3cd65ee 100644 --- a/tests/RivalEndpointTest.php +++ b/tests/RivalEndpointTest.php @@ -17,17 +17,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::RIVAL_COLLECTION_DATA, 'rivals', 'getAll', - [], - Rival::class, - 'assertResponse' + [] ]; yield 'get all by team id' => [ MockResponse::RIVAL_COLLECTION_DATA, 'rivals', 'getAllByTeamId', - [1], - Rival::class, - 'assertResponse' + [1] ]; } diff --git a/tests/RoundEndpointTest.php b/tests/RoundEndpointTest.php index 7b629ba..3c0b1df 100644 --- a/tests/RoundEndpointTest.php +++ b/tests/RoundEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::ROUND_ITEM_DATA, 'rounds', 'getById', - [1], - Round::class, - 'assertResponse' + [1] ]; } @@ -33,25 +31,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::ROUND_COLLECTION_DATA, 'rounds', 'getAll', - [], - Round::class, - 'assertResponse' + [] ]; yield 'get all by season id' => [ MockResponse::ROUND_COLLECTION_DATA, 'rounds', 'getAllBySeasonId', - [1], - Round::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::ROUND_COLLECTION_DATA, 'rounds', 'getAllBySearchQuery', - ['test'], - Round::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/ScheduleEndpointTest.php b/tests/ScheduleEndpointTest.php index 139eb36..b24ba8f 100644 --- a/tests/ScheduleEndpointTest.php +++ b/tests/ScheduleEndpointTest.php @@ -15,25 +15,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::STAGE_COLLECTION_DATA, 'schedules', 'getAllBySeasonId', - [1], - Stage::class, - 'assertResponse' + [1] ]; yield 'get all by team id' => [ MockResponse::STAGE_COLLECTION_DATA, 'schedules', 'getAllByTeamId', - [1], - Stage::class, - 'assertResponse' + [1] ]; yield 'get all by season id and team id' => [ MockResponse::STAGE_COLLECTION_DATA, 'schedules', 'getAllBySeasonIdAndTeamId', - [1, 1], - Stage::class, - 'assertResponse' + [1, 1] ]; } diff --git a/tests/SeasonEndpointTest.php b/tests/SeasonEndpointTest.php index 1f9af9e..c182825 100644 --- a/tests/SeasonEndpointTest.php +++ b/tests/SeasonEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::SEASON_ITEM_DATA, 'seasons', 'getById', - [1], - Season::class, - 'assertResponse' + [1] ]; } @@ -33,25 +31,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::SEASON_COLLECTION_DATA, 'seasons', 'getAll', - [], - Season::class, - 'assertResponse' + [] ]; yield 'get all by team id' => [ MockResponse::SEASON_COLLECTION_DATA, 'seasons', 'getAllByTeamId', - [1], - Season::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::SEASON_COLLECTION_DATA, 'seasons', 'getAllBySearchQuery', - ['test'], - Season::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/StageEndpointTest.php b/tests/StageEndpointTest.php index 3b00eb4..dcf6fa7 100644 --- a/tests/StageEndpointTest.php +++ b/tests/StageEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::STAGE_ITEM_DATA, 'stages', 'getById', - [1], - Stage::class, - 'assertResponse' + [1] ]; } @@ -33,25 +31,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::STAGE_COLLECTION_DATA, 'stages', 'getAll', - [], - Stage::class, - 'assertResponse' + [] ]; yield 'get all by season id' => [ MockResponse::STAGE_COLLECTION_DATA, 'stages', 'getAllBySeasonId', - [1], - Stage::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::STAGE_COLLECTION_DATA, 'stages', 'getAllBySearchQuery', - ['test'], - Stage::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/StandingEndpointTest.php b/tests/StandingEndpointTest.php index 7c56447..207fdac 100644 --- a/tests/StandingEndpointTest.php +++ b/tests/StandingEndpointTest.php @@ -19,7 +19,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'standings', 'getAll', [], - Standing::class, 'assertStandingResponse' ]; yield 'get all by season id' => [ @@ -27,7 +26,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'standings', 'getAllBySeasonId', [1], - Standing::class, 'assertStandingResponse' ]; yield 'get all corrections by season id' => [ @@ -35,7 +33,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'standings', 'getAllCorrectionsBySeasonId', [1], - StandingCorrection::class, 'assertStandingCorrectionResponse' ]; yield 'get all by round id' => [ @@ -43,7 +40,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'standings', 'getAllByRoundId', [1], - Standing::class, 'assertStandingResponse' ]; yield 'get all live by league id' => [ @@ -51,7 +47,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'standings', 'getAllLiveByLeagueId', [1], - Standing::class, 'assertStandingResponse' ]; } diff --git a/tests/StateEndpointTest.php b/tests/StateEndpointTest.php index dec848a..72b924f 100644 --- a/tests/StateEndpointTest.php +++ b/tests/StateEndpointTest.php @@ -19,9 +19,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::STATE_ITEM_DATA, 'states', 'getById', - [1], - State::class, - 'assertResponse' + [1] ]; } @@ -31,9 +29,7 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::STATE_COLLECTION_DATA, 'states', 'getAll', - [], - State::class, - 'assertResponse' + [] ]; } diff --git a/tests/StatisticEndpointTest.php b/tests/StatisticEndpointTest.php index 7637199..b5a201d 100644 --- a/tests/StatisticEndpointTest.php +++ b/tests/StatisticEndpointTest.php @@ -26,7 +26,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'statistics', 'getAllByPlayerId', [1], - PlayerStatistic::class, 'assertPlayerStatisticResponse' ]; yield 'get all by team id' => [ @@ -34,7 +33,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'statistics', 'getAllByTeamId', [1], - TeamStatistic::class, 'assertTeamStatisticResponse' ]; yield 'get all by coach id' => [ @@ -42,7 +40,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'statistics', 'getAllByCoachId', [1], - CoachStatistic::class, 'assertCoachStatisticResponse' ]; yield 'get all by referee id' => [ @@ -50,7 +47,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'statistics', 'getAllByRefereeId', [1], - RefereeStatistic::class, 'assertRefereeStatisticResponse' ]; yield 'get all by stage id' => [ @@ -58,7 +54,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'statistics', 'getAllByStageId', [1], - Statistic::class, 'assertStatisticResponse' ]; yield 'get all by round id' => [ @@ -66,7 +61,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'statistics', 'getAllByRoundId', [1], - Statistic::class, 'assertStatisticResponse' ]; } diff --git a/tests/TeamEndpointTest.php b/tests/TeamEndpointTest.php index 93f22e6..c75b433 100644 --- a/tests/TeamEndpointTest.php +++ b/tests/TeamEndpointTest.php @@ -22,7 +22,6 @@ public static function provideEndpointItemResponseData(): \Generator 'teams', 'getById', [1], - Team::class, 'assertResponse' ]; } @@ -33,33 +32,25 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::TEAM_COLLECTION_DATA, 'teams', 'getAll', - [], - Team::class, - 'assertResponse' + [] ]; yield 'get all by country id' => [ MockResponse::TEAM_COLLECTION_DATA, 'teams', 'getAllByCountryId', - [1], - Team::class, - 'assertResponse' + [1] ]; yield 'get all by season id' => [ MockResponse::TEAM_COLLECTION_DATA, 'teams', 'getAllBySeasonId', - [1], - Team::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::TEAM_COLLECTION_DATA, 'teams', 'getAllBySearchQuery', - ['test'], - Team::class, - 'assertResponse' + ['test'] ]; } diff --git a/tests/TeamSquadEndpointTest.php b/tests/TeamSquadEndpointTest.php index 0b8943b..921bbb5 100644 --- a/tests/TeamSquadEndpointTest.php +++ b/tests/TeamSquadEndpointTest.php @@ -15,17 +15,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::TEAM_SQUAD_COLLECTION_DATA, 'teamSquads', 'getAllByTeamId', - [1], - TeamSquad::class, - 'assertResponse' + [1] ]; yield 'get all by season id and team id' => [ MockResponse::TEAM_SQUAD_COLLECTION_DATA, 'teamSquads', 'getAllBySeasonIdAndTeamId', - [1, 1], - TeamSquad::class, - 'assertResponse' + [1, 1] ]; } diff --git a/tests/TopscorerEndpointTest.php b/tests/TopscorerEndpointTest.php index 8a55d8a..185fa2c 100644 --- a/tests/TopscorerEndpointTest.php +++ b/tests/TopscorerEndpointTest.php @@ -17,17 +17,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::TOPSCORER_COLLECTION_DATA, 'topscorers', 'getAllBySeasonId', - [1], - Topscorer::class, - 'assertResponse' + [1] ]; yield 'get all by stage id' => [ MockResponse::TOPSCORER_COLLECTION_DATA, 'topscorers', 'getAllByStageId', - [1], - Topscorer::class, - 'assertResponse' + [1] ]; } diff --git a/tests/TransferEndpointTest.php b/tests/TransferEndpointTest.php index 65931b7..5b95fd0 100644 --- a/tests/TransferEndpointTest.php +++ b/tests/TransferEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::TRANSFER_ITEM_DATA, 'transfers', 'getById', - [1], - Transfer::class, - 'assertResponse' + [1] ]; } @@ -33,41 +31,31 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::TRANSFER_COLLECTION_DATA, 'transfers', 'getAll', - [], - Transfer::class, - 'assertResponse' + [] ]; yield 'get all latest' => [ MockResponse::TRANSFER_COLLECTION_DATA, 'transfers', 'getAllLatest', - [], - Transfer::class, - 'assertResponse' + [] ]; yield 'get all by date range' => [ MockResponse::TRANSFER_COLLECTION_DATA, 'transfers', 'getAllByDateRange', - [new \DateTime('yesterday'), new \DateTime('today')], - Transfer::class, - 'assertResponse' + [new \DateTime('yesterday'), new \DateTime('today')] ]; yield 'get all by team id' => [ MockResponse::TRANSFER_COLLECTION_DATA, 'transfers', 'getAllByTeamId', - [1], - Transfer::class, - 'assertResponse' + [1] ]; yield 'get all by player id' => [ MockResponse::TRANSFER_COLLECTION_DATA, 'transfers', 'getAllByPlayerId', - [1], - Transfer::class, - 'assertResponse' + [1] ]; } diff --git a/tests/TvStationEndpointTest.php b/tests/TvStationEndpointTest.php index 13c5cbd..e52fd69 100644 --- a/tests/TvStationEndpointTest.php +++ b/tests/TvStationEndpointTest.php @@ -19,9 +19,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::TV_STATION_ITEM_DATA, 'tvStations', 'getById', - [1], - TvStation::class, - 'assertResponse' + [1] ]; } @@ -31,17 +29,13 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::TV_STATION_COLLECTION_DATA, 'tvStations', 'getAll', - [], - TvStation::class, - 'assertResponse' + [] ]; yield 'get all by fixture id' => [ MockResponse::TV_STATION_COLLECTION_DATA, 'tvStations', 'getAllByFixtureId', - [1], - TvStation::class, - 'assertResponse' + [1] ]; } diff --git a/tests/TypeEndpointTest.php b/tests/TypeEndpointTest.php index acbd393..98c3323 100644 --- a/tests/TypeEndpointTest.php +++ b/tests/TypeEndpointTest.php @@ -21,7 +21,6 @@ public static function provideEndpointItemResponseData(): \Generator 'types', 'getById', [1], - Type::class, 'assertTypeResponse' ]; } @@ -33,7 +32,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'types', 'getAll', [], - Type::class, 'assertTypeResponse' ]; yield 'get all by entity' => [ @@ -41,7 +39,6 @@ public static function provideEndpointCollectionResponseData(): \Generator 'types', 'getAllByEntity', [], - TypeEntity::class, 'assertEntityResponse' ]; } diff --git a/tests/Util/TestEndpointCollectionResponseTrait.php b/tests/Util/TestEndpointCollectionResponseTrait.php index 3169c83..5c3eb09 100644 --- a/tests/Util/TestEndpointCollectionResponseTrait.php +++ b/tests/Util/TestEndpointCollectionResponseTrait.php @@ -14,8 +14,7 @@ public function testEndpointCollectionResponse( string $endpointName, string $methodName, array $methodParams, - string $entityClass, - string $assertion + string $callback = 'assertResponse' ): void { $this->mockHttpClient->addResponse(new Response( @@ -23,10 +22,7 @@ public function testEndpointCollectionResponse( )); $response = $this->givenApi()->$endpointName()->$methodName(...$methodParams); - - $data = $response->getData(); - $this->assertContainsOnlyInstancesOf($entityClass, $data); - $this->$assertion($data[0]); + $this->$callback($response->getData()[0]); } public abstract static function provideEndpointCollectionResponseData(): \Generator; diff --git a/tests/Util/TestEndpointItemResponseTrait.php b/tests/Util/TestEndpointItemResponseTrait.php index 30cda6a..a8d398c 100644 --- a/tests/Util/TestEndpointItemResponseTrait.php +++ b/tests/Util/TestEndpointItemResponseTrait.php @@ -14,8 +14,7 @@ public function testEndpointItemResponse( string $endpointName, string $methodName, array $methodParams, - string $entityClass, - string $assertion + string $callback = 'assertResponse' ): void { $this->mockHttpClient->addResponse(new Response( @@ -25,8 +24,7 @@ public function testEndpointItemResponse( $response = $this->givenApi()->$endpointName()->$methodName(...$methodParams); $data = $response->getData(); - $this->assertInstanceOf($entityClass, $data); - $this->$assertion($data); + $this->$callback($data); } public abstract static function provideEndpointItemResponseData(): \Generator; diff --git a/tests/VenueEndpointTest.php b/tests/VenueEndpointTest.php index c450be7..252ce72 100644 --- a/tests/VenueEndpointTest.php +++ b/tests/VenueEndpointTest.php @@ -21,9 +21,7 @@ public static function provideEndpointItemResponseData(): \Generator MockResponse::VENUE_ITEM_DATA, 'venues', 'getById', - [1], - Venue::class, - 'assertResponse' + [1] ]; } @@ -33,25 +31,19 @@ public static function provideEndpointCollectionResponseData(): \Generator MockResponse::VENUE_COLLECTION_DATA, 'venues', 'getAll', - [], - Venue::class, - 'assertResponse' + [] ]; yield 'get all by season id' => [ MockResponse::VENUE_COLLECTION_DATA, 'venues', 'getAllBySeasonId', - [1], - Venue::class, - 'assertResponse' + [1] ]; yield 'get all by search query' => [ MockResponse::VENUE_COLLECTION_DATA, 'venues', 'getAllBySearchQuery', - ['test'], - Venue::class, - 'assertResponse' + ['test'] ]; } From 28dcada647f96ac76794dfa2a730d8c35bcb1998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pimpa=CC=83o?= Date: Mon, 20 Nov 2023 13:41:07 +0000 Subject: [PATCH 4/6] chore: added timezone tests --- tests/TimezoneEndpointTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/TimezoneEndpointTest.php diff --git a/tests/TimezoneEndpointTest.php b/tests/TimezoneEndpointTest.php new file mode 100644 index 0000000..da1a5e3 --- /dev/null +++ b/tests/TimezoneEndpointTest.php @@ -0,0 +1,25 @@ + [ + MockResponse::TIMEZONE_COLLECTION_DATA, + 'timezones', + 'getAll', + [] + ]; + } + + private function assertResponse(string $timezone): void + { + $this->assertSame('Africa/Abidjan', $timezone); + } +} \ No newline at end of file From debe7267c2aa86e6e7c80ffc3cdafab7bae876f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pimpa=CC=83o?= Date: Mon, 20 Nov 2023 17:07:07 +0000 Subject: [PATCH 5/6] chore: added missing test --- tests/SportMonksFootballTest.php | 2 ++ tests/Util/TestEndpointCollectionResponseTrait.php | 4 ++-- tests/Util/TestEndpointItemResponseTrait.php | 6 ++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/SportMonksFootballTest.php b/tests/SportMonksFootballTest.php index e023357..99f7c93 100644 --- a/tests/SportMonksFootballTest.php +++ b/tests/SportMonksFootballTest.php @@ -29,6 +29,7 @@ use ProgrammatorDev\SportMonksFootball\Endpoint\StatisticEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TeamEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TeamSquadEndpoint; +use ProgrammatorDev\SportMonksFootball\Endpoint\TimezoneEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TopscorerEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TransferEndpoint; use ProgrammatorDev\SportMonksFootball\Endpoint\TvStationEndpoint; @@ -71,6 +72,7 @@ public static function provideMethodsData(): \Generator yield 'statistics' => [StatisticEndpoint::class, 'statistics']; yield 'teams' => [TeamEndpoint::class, 'teams']; yield 'team squads' => [TeamSquadEndpoint::class, 'teamSquads']; + yield 'timezones' => [TimezoneEndpoint::class, 'timezones']; yield 'topscorers' => [TopscorerEndpoint::class, 'topscorers']; yield 'transfers' => [TransferEndpoint::class, 'transfers']; yield 'tv stations' => [TvStationEndpoint::class, 'tvStations']; diff --git a/tests/Util/TestEndpointCollectionResponseTrait.php b/tests/Util/TestEndpointCollectionResponseTrait.php index 5c3eb09..bcaccd5 100644 --- a/tests/Util/TestEndpointCollectionResponseTrait.php +++ b/tests/Util/TestEndpointCollectionResponseTrait.php @@ -14,7 +14,7 @@ public function testEndpointCollectionResponse( string $endpointName, string $methodName, array $methodParams, - string $callback = 'assertResponse' + string $assertCallback = 'assertResponse' ): void { $this->mockHttpClient->addResponse(new Response( @@ -22,7 +22,7 @@ public function testEndpointCollectionResponse( )); $response = $this->givenApi()->$endpointName()->$methodName(...$methodParams); - $this->$callback($response->getData()[0]); + $this->$assertCallback($response->getData()[0]); } public abstract static function provideEndpointCollectionResponseData(): \Generator; diff --git a/tests/Util/TestEndpointItemResponseTrait.php b/tests/Util/TestEndpointItemResponseTrait.php index a8d398c..43cd44e 100644 --- a/tests/Util/TestEndpointItemResponseTrait.php +++ b/tests/Util/TestEndpointItemResponseTrait.php @@ -14,7 +14,7 @@ public function testEndpointItemResponse( string $endpointName, string $methodName, array $methodParams, - string $callback = 'assertResponse' + string $assertCallback = 'assertResponse' ): void { $this->mockHttpClient->addResponse(new Response( @@ -22,9 +22,7 @@ public function testEndpointItemResponse( )); $response = $this->givenApi()->$endpointName()->$methodName(...$methodParams); - - $data = $response->getData(); - $this->$callback($data); + $this->$assertCallback($response->getData()); } public abstract static function provideEndpointItemResponseData(): \Generator; From a3e7a611b06ef7c65d149f162e5bceffb500b40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pimpa=CC=83o?= Date: Mon, 20 Nov 2023 17:14:32 +0000 Subject: [PATCH 6/6] chore: added Timezone documentation --- docs/03-supported-endpoints.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/03-supported-endpoints.md b/docs/03-supported-endpoints.md index 2264b6b..999c5db 100644 --- a/docs/03-supported-endpoints.md +++ b/docs/03-supported-endpoints.md @@ -33,6 +33,7 @@ - [Countries](#countries) - [Filters](#filters) - [Regions](#regions) + - [Timezones](#timezones) - [Types](#types) - [Select, Include and Filters](#select-include-and-filters) - [withSelect](#withselect) @@ -2139,6 +2140,27 @@ foreach ($regions->getData() as $region) { } ``` +### Timezones + +- [Official documentation](https://docs.sportmonks.com/football/v/core-api/endpoints/timezones) +- Cache default max age: `1 day` + +#### `getAll` + +```php +getAll(): TimezoneCollection +``` + +Get all timezones: + +```php +$timezones = $sportMonksFootball->timezones()->getAll(); + +foreach ($timezones->getData() as $timezone) { + echo $timezone; +} +``` + ### Types - [Official documentation](https://docs.sportmonks.com/football/v/core-api/endpoints/types)