Skip to content

Commit

Permalink
When key is not found when fetching a specific event report, empty ar…
Browse files Browse the repository at this point in the history
…ray is returned. This is consistent with the empty array that's returned when there are no objects on the chart, and a general report is requested.
  • Loading branch information
mroloux committed Nov 21, 2018
1 parent 383b635 commit d44ccc8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Reports/EventReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private static function mapMultiValuedReport($json, $filter)
if (array_key_exists($filter, $result)) {
return $result[$filter];
}
return null;
return [];
}

private static function reportUrl($reportType, $eventKey, $filter)
Expand Down
11 changes: 10 additions & 1 deletion tests/EventReports/EventReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public function testByStatus()
self::assertCount(31, $report[ObjectStatus::$FREE]);
}

public function testByStatus_emptyChart()
{
$chartKey = $this->seatsioClient->charts->create()->key;
$event = $this->seatsioClient->events->create($chartKey);

$report = $this->seatsioClient->eventReports->byStatus($event->key);
self::assertEquals([], $report);
}

public function testBySpecificStatus()
{
$chartKey = $this->createTestChart();
Expand All @@ -92,7 +101,7 @@ public function testBySpecificNonExistingStatus()
$event = $this->seatsioClient->events->create($chartKey);

$report = $this->seatsioClient->eventReports->byStatus($event->key, "lolzor");
self::assertNull($report);
self::assertEquals([], $report);
}

public function testByCategoryLabel()
Expand Down

0 comments on commit d44ccc8

Please sign in to comment.