Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix league lookup exception #18

Merged
merged 3 commits into from
May 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.2] - To be released

### Fixed
- League serializer should handle `null` response if ID was not found
- Event serializer should handle `null` response if ID was not found
- Skip schedule tests at the beginning and ending of the season

## [1.0.1] - 2021-05-04

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions src/Serializer/Event/EventSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ protected function getValidJsonRootNames(): array
{
return ['event', 'events', 'results'];
}

protected function endpointReturnsNull(): bool
{
return true;
}
}
5 changes: 5 additions & 0 deletions src/Serializer/LeagueSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ protected function getValidJsonRootNames(): array
{
return ['countrys', 'leagues'];
}

protected function endpointReturnsNull(): bool
{
return true;
}
}
21 changes: 21 additions & 0 deletions test/integration/ScheduleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public function testTeamNext(): void
$events = $this->client->schedule()->teamNext(133602);
$this->assertContainsOnlyInstancesOf(Event::class, $events);

// There are no events to check at the ending of a season
if (empty($events)) {
$this->markTestSkipped('No events to check');
}

$event = $events[0];
$this->assertTrue('Liverpool' === $event->strHomeTeam || 'Liverpool' === $event->strAwayTeam);
}
Expand All @@ -47,6 +52,11 @@ public function testLeagueNext(): void
TestUtils::setPatreonKey($this->client);
$events = $this->client->schedule()->leagueNext(4328);

// There are no events to check at the ending of a season
if (empty($events)) {
$this->markTestSkipped('No events to check');
}

$this->assertContainsOnlyInstancesOf(Event::class, $events);
$this->assertSame('English Premier League', $events[0]->strLeague);
}
Expand All @@ -61,6 +71,11 @@ public function testTeamLast(): void
$events = $this->client->schedule()->teamLast(133602);
$this->assertContainsOnlyInstancesOf(Event::class, $events);

// There are no events to check at the beginning of a season
if (empty($events)) {
$this->markTestSkipped('No events to check');
}

$event = $events[0];
$this->assertTrue('Liverpool' === $event->strHomeTeam || 'Liverpool' === $event->strAwayTeam);
}
Expand All @@ -73,6 +88,12 @@ public function testTeamLast(): void
public function testLeagueLast(): void
{
$events = $this->client->schedule()->leagueLast(4328);

// There are no events to check at the beginning of a season
if (empty($events)) {
$this->markTestSkipped('No events to check');
}

$this->assertContainsOnlyInstancesOf(Event::class, $events);
$this->assertSame('English Premier League', $events[0]->strLeague);
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Serializer/ExtendedSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public function serializerProvider(): array
[ContractSerializer::class, false],
[CountrySerializer::class, false],
[EntrySerializer::class, false],
[EventSerializer::class, false],
[EventSerializer::class, true],
[FormerTeamSerializer::class, false],
[HighlightSerializer::class, false],
[HonorSerializer::class, false],
[LeagueSerializer::class, false],
[LeagueSerializer::class, true],
[LineupSerializer::class, false],
[LivescoreSerializer::class, true],
[LoveSerializer::class, false],
Expand Down