feat: all-season assignments
This commit is contained in:
1 parent
675cec1b69
commit
cf876ed224
119 files changed
+6194
-294
No files matched your search
@@ -71,6 +71,52 @@ class SeasonCalendarTest extends TestCase
|
||||
(new SeasonCalendar('xx-yy', '04-01'))->seasonYearFor(new \DateTimeImmutable('2025-01-01'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider currentOrUpcomingDates
|
||||
*/
|
||||
public function testCurrentOrUpcomingSeasonYear(string $date, int $expected): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->winter()->currentOrUpcomingSeasonYear(new \DateTimeImmutable($date))
|
||||
);
|
||||
}
|
||||
|
||||
public static function currentOrUpcomingDates(): iterable
|
||||
{
|
||||
yield 'inside the season' => ['2024-12-20', 2024];
|
||||
yield 'last day of the season' => ['2025-04-01', 2024];
|
||||
yield 'day after the season ends falls forward' => ['2025-04-02', 2025];
|
||||
yield 'high summer falls forward' => ['2025-07-15', 2025];
|
||||
yield 'day before the next season starts' => ['2025-10-31', 2025];
|
||||
yield 'first day of the next season' => ['2025-11-01', 2025];
|
||||
yield 'off-season in january is impossible for this window' => ['2025-01-05', 2024];
|
||||
}
|
||||
|
||||
public function testCurrentOrUpcomingSeasonYearFallsForwardAcrossTheTurnOfTheYear(): void
|
||||
{
|
||||
// A window that ends before it starts in the same calendar year is the wrapping case;
|
||||
// one that does not wrap has its off-season on both sides of the window instead.
|
||||
$summer = new SeasonCalendar('05-01', '09-30');
|
||||
|
||||
$this->assertSame(2025, $summer->currentOrUpcomingSeasonYear(new \DateTimeImmutable('2025-03-01')));
|
||||
$this->assertSame(2025, $summer->currentOrUpcomingSeasonYear(new \DateTimeImmutable('2025-06-01')));
|
||||
$this->assertSame(2026, $summer->currentOrUpcomingSeasonYear(new \DateTimeImmutable('2025-11-20')));
|
||||
}
|
||||
|
||||
public function testWindowFor(): void
|
||||
{
|
||||
[$start, $end] = $this->winter()->windowFor(2024);
|
||||
|
||||
$this->assertSame('2024-11-01', $start->format('Y-m-d'));
|
||||
$this->assertSame('2025-04-01', $end->format('Y-m-d'));
|
||||
|
||||
[$start, $end] = (new SeasonCalendar('05-01', '09-30'))->windowFor(2025);
|
||||
|
||||
$this->assertSame('2025-05-01', $start->format('Y-m-d'));
|
||||
$this->assertSame('2025-09-30', $end->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideUpcomingSeasonDates
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Config;
|
||||
|
||||
use App\Config\SeasonTask;
|
||||
use App\Config\SeasonTaskProvision;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* The enum is the single source of truth for the checklist, so what is pinned here is the
|
||||
* agreed entry list itself: adding or changing an entry is a decision the office makes, not
|
||||
* something that should slip in unnoticed.
|
||||
*/
|
||||
class SeasonTaskTest extends TestCase
|
||||
{
|
||||
public function testEveryCaseResolvesALabelAndADistinctKey(): void
|
||||
{
|
||||
$keys = [];
|
||||
$labels = [];
|
||||
|
||||
foreach (SeasonTask::cases() as $case) {
|
||||
$this->assertNotSame('', $case->label(), sprintf('%s has no label', $case->name));
|
||||
|
||||
$keys[] = $case->value;
|
||||
$labels[] = $case->label();
|
||||
}
|
||||
|
||||
$this->assertSame($keys, array_unique($keys));
|
||||
$this->assertSame($labels, array_unique($labels));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider entries
|
||||
*/
|
||||
public function testTheAgreedEntryList(
|
||||
SeasonTask $task,
|
||||
string $label,
|
||||
SeasonTaskProvision $provides,
|
||||
bool $requiresReturn,
|
||||
): void {
|
||||
$this->assertSame($label, $task->label());
|
||||
$this->assertSame($provides, $task->provides());
|
||||
$this->assertSame($requiresReturn, $task->requiresReturn());
|
||||
}
|
||||
|
||||
public static function entries(): iterable
|
||||
{
|
||||
yield [SeasonTask::MASTER_DATA, 'Stammdaten', SeasonTaskProvision::STANDARD, true];
|
||||
yield [SeasonTask::VEHICLE, 'KfZ', SeasonTaskProvision::STANDARD, true];
|
||||
yield [SeasonTask::CONTRACT, 'Vertrag', SeasonTaskProvision::INDIVIDUAL, true];
|
||||
yield [SeasonTask::ADDITIONAL_CONTRACT, 'Zusatzvertrag', SeasonTaskProvision::INDIVIDUAL, true];
|
||||
yield [SeasonTask::SAAS_REGISTERED, 'SaaS angemeldet', SeasonTaskProvision::NONE, false];
|
||||
yield [SeasonTask::MUNICIPALITY_REGISTERED, 'Gemeinde angemeldet', SeasonTaskProvision::NONE, false];
|
||||
}
|
||||
|
||||
public function testAnEntryThatHandsNothingOutNeverExpectsSomethingBack(): void
|
||||
{
|
||||
// the two are independent properties, but "nothing out and something back" would be a
|
||||
// task the teamer is reminded about without ever being given anything to return
|
||||
foreach (SeasonTask::cases() as $case) {
|
||||
if (SeasonTaskProvision::NONE === $case->provides()) {
|
||||
$this->assertFalse($case->requiresReturn(), sprintf('%s expects a return', $case->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testRequiringReturnIsTheTeamerFacingSubsetInEnumOrder(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
[
|
||||
SeasonTask::MASTER_DATA,
|
||||
SeasonTask::VEHICLE,
|
||||
SeasonTask::CONTRACT,
|
||||
SeasonTask::ADDITIONAL_CONTRACT,
|
||||
],
|
||||
SeasonTask::requiringReturn()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user