-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposed usage report cutoff date (#98)
- Loading branch information
Showing
19 changed files
with
171 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Reports/Usage/SummaryForMonths/UsageSummaryForAllMonths.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
|
||
namespace Seatsio\Reports\Usage\SummaryForMonths; | ||
|
||
|
||
class UsageSummaryForAllMonths | ||
{ | ||
|
||
/** | ||
* @var \DateTime | ||
*/ | ||
public $usageCutoffDate; | ||
|
||
/** | ||
* @var UsageSummaryForMonth[] | ||
*/ | ||
public $usage; | ||
|
||
/** | ||
* @param \DateTime $usageCutoffDate | ||
* @param UsageSummaryForMonth[] $usage | ||
*/ | ||
public function __construct(\DateTime $usageCutoffDate = null, array $usage = null) | ||
{ | ||
$this->usageCutoffDate = $usageCutoffDate; | ||
$this->usage = $usage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Reports/ChartReportsSummaryTest.php → ...eports/Charts/ChartReportsSummaryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Reports/ChartReportsTest.php → tests/Reports/Charts/ChartReportsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Seatsio\Reports; | ||
namespace Reports\Charts; | ||
|
||
use Seatsio\Common\IDs; | ||
use Seatsio\SeatsioClient; | ||
|
2 changes: 1 addition & 1 deletion
2
...s/Reports/EventReportsDeepSummaryTest.php → ...ts/Events/EventReportsDeepSummaryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Reports/EventReportsSummaryTest.php → ...eports/Events/EventReportsSummaryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Reports/EventReportsTest.php → tests/Reports/Events/EventReportsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Seatsio\Reports; | ||
namespace Reports\Events; | ||
|
||
use Seatsio\Common\IDs; | ||
use Seatsio\Events\Channel; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Reports\Usage; | ||
|
||
use Seatsio\Reports\Usage\DetailsForEventInMonth\UsageForObjectV1; | ||
use Seatsio\Reports\Usage\DetailsForMonth\Event; | ||
use Seatsio\Reports\Usage\DetailsForMonth\UsageByEvent; | ||
use Seatsio\Reports\Usage\SummaryForMonths\Month; | ||
use Seatsio\SeatsioClientTest; | ||
|
||
class UsageReportTest extends SeatsioClientTest | ||
{ | ||
public function testUsageReportForAllMonths() | ||
{ | ||
$this->skipTestIfDemoCompanySecretKeyNotSet(); | ||
$client = $this->createSeatsioClient($this->demoCompanySecretKey()); | ||
|
||
$report = $client->usageReports->summaryForAllMonths(); | ||
|
||
self::assertNotNull($report->usageCutoffDate); | ||
self::assertGreaterThan(0, count($report->usage)); | ||
self::assertEquals(new Month(2014, 2), $report->usage[0]->month); | ||
} | ||
|
||
public function testUsageReportForMonth() | ||
{ | ||
$this->skipTestIfDemoCompanySecretKeyNotSet(); | ||
$client = $this->createSeatsioClient($this->demoCompanySecretKey()); | ||
|
||
$report = $client->usageReports->detailsForMonth(new Month(2021, 11)); | ||
|
||
self::assertGreaterThan(0, count($report)); | ||
self::assertGreaterThan(0, count($report[0]->usageByChart)); | ||
$expected = new UsageByEvent(new Event(580293, "largeStadiumEvent", false), 143); | ||
self::assertEquals([$expected], $report[0]->usageByChart[0]->usageByEvent); | ||
} | ||
|
||
public function testUsageReportForEventInMonth() | ||
{ | ||
$this->skipTestIfDemoCompanySecretKeyNotSet(); | ||
$client = $this->createSeatsioClient($this->demoCompanySecretKey()); | ||
|
||
$report = $client->usageReports->detailsForEventInMonth(580293, new Month(2021, 11)); | ||
|
||
self::assertGreaterThan(0, count($report)); | ||
$expected = new UsageForObjectV1('102-9-14', 0, null, 1, 1); | ||
self::assertEquals($expected, $report[0]); | ||
} | ||
|
||
private function skipTestIfDemoCompanySecretKeyNotSet(): void | ||
{ | ||
if (!$this->isDemoCompanySecretKeySet()) { | ||
$this->markTestSkipped("DEMO_COMPANY_SECRET_KEY environment variable not set"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters