63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Dashboard\Stats;
|
|
|
|
use App\Dashboard\Stats\Series;
|
|
use App\Dashboard\Stats\SeriesResult;
|
|
use InvalidArgumentException;
|
|
use Tests\TestCase;
|
|
|
|
class SeriesResultTest extends TestCase
|
|
{
|
|
public function test_a_series_result_aligns_every_series_to_the_shared_label_axis(): void
|
|
{
|
|
$this->expectException(InvalidArgumentException::class);
|
|
|
|
new SeriesResult(
|
|
['2026-07-01', '2026-07-02', '2026-07-03'],
|
|
[new Series('Approved', [1, 2])],
|
|
);
|
|
}
|
|
|
|
public function test_a_series_result_accepts_multiple_series_that_all_align(): void
|
|
{
|
|
$result = new SeriesResult(
|
|
['2026-07-01', '2026-07-02'],
|
|
[
|
|
new Series('Approved', [1, 2]),
|
|
new Series('Rejected', [0, 1]),
|
|
],
|
|
);
|
|
|
|
$this->assertSame(['2026-07-01', '2026-07-02'], $result->labels);
|
|
$this->assertCount(2, $result->series);
|
|
}
|
|
|
|
public function test_a_too_wide_result_reports_itself_as_too_wide(): void
|
|
{
|
|
$result = SeriesResult::tooWide();
|
|
|
|
$this->assertTrue($result->isTooWide());
|
|
}
|
|
|
|
public function test_a_too_wide_result_is_not_reported_as_merely_empty(): void
|
|
{
|
|
$result = SeriesResult::tooWide();
|
|
|
|
$this->assertFalse($result->isEmpty());
|
|
}
|
|
|
|
public function test_an_empty_but_valid_result_is_not_reported_as_too_wide(): void
|
|
{
|
|
$result = new SeriesResult([], []);
|
|
|
|
$this->assertFalse($result->isTooWide());
|
|
}
|
|
|
|
public function test_an_empty_but_valid_result_reports_itself_as_empty(): void
|
|
{
|
|
$result = new SeriesResult([], []);
|
|
|
|
$this->assertTrue($result->isEmpty());
|
|
}
|
|
}
|