refactor: derive the bus escort from the travel date

This commit is contained in:
fromme committed 2026-10-16 08:36:54 +02:00
1 parent 2fc9806c69
commit 0e2021e96d
9 files changed
+59 -50

No files matched your search

@@ -85,14 +85,14 @@ class AssignmentPlannerTest extends TestCase
['busProId' => 5, 'city' => 'Göttingen', 'street' => null, 'time' => '08.03.2024 22:00:00'],
]);
$planned = $this->plan(self::rule(guides: 2, busEscort: true), $destination);
$planned = $this->plan(self::rule(guides: 2), $destination);
$this->assertSame(5, $planned[0]->pickup);
}
public function testTheBusEscortIsSetOnExactlyOneAssignment(): void
{
$planned = $this->plan(self::rule(guides: 3, beginner: true, split: true, busEscort: true));
$planned = $this->plan(self::rule(guides: 3, beginner: true, split: true), self::busTravel());
$this->assertSame([
[StaffingRole::GUIDE, 2, 5, []],
@@ -102,7 +102,7 @@ class AssignmentPlannerTest extends TestCase
public function testWithoutAPlainReiseleitungTheFirstCombinedOneEscortsTheBus(): void
{
$planned = $this->plan(self::rule(guides: 2, beginner: true, advanced: true, split: true, busEscort: true));
$planned = $this->plan(self::rule(guides: 2, beginner: true, advanced: true, split: true), self::busTravel());
$this->assertSame(5, $planned[0]->pickup);
$this->assertNull($planned[1]->pickup);
@@ -110,16 +110,16 @@ class AssignmentPlannerTest extends TestCase
public function testNoBusEscortWithoutBoardingPoints(): void
{
$planned = $this->plan(self::rule(guides: 1, busEscort: true), self::destination([]));
$planned = $this->plan(self::rule(guides: 1));
$this->assertNull($planned[0]->pickup);
}
public function testNoBusEscortWhenTheMatrixSaysNo(): void
public function testWithoutAGuideNobodyEscortsTheBus(): void
{
$planned = $this->plan(self::rule(guides: 1));
$planned = $this->plan(self::rule(guides: 0, beginner: true), self::busTravel());
$this->assertNull($planned[0]->pickup);
$this->assertSame([[StaffingRole::SKI_BEGINNER, 1, null, [StaffingFee::COURSE]]], self::summarize($planned));
}
/**
@@ -127,9 +127,14 @@ class AssignmentPlannerTest extends TestCase
*/
private function plan(StaffingRule $rule, ?Destination $destination = null): array
{
return (new AssignmentPlanner())->plan($rule, $destination ?? self::destination([
return (new AssignmentPlanner())->plan($rule, $destination ?? self::destination([]));
}
private static function busTravel(): Destination
{
return self::destination([
['busProId' => 5, 'city' => 'Göttingen', 'street' => null, 'time' => '08.03.2024 22:00:00'],
]));
]);
}
/**
@@ -149,7 +154,6 @@ class AssignmentPlannerTest extends TestCase
bool $advanced = false,
bool $split = false,
bool $guiding = false,
bool $busEscort = false,
): StaffingRule {
return (new StaffingRule())
->setProductCode('DKIMP')
@@ -158,7 +162,6 @@ class AssignmentPlannerTest extends TestCase
->setSkiAdvanced($advanced)
->setSplit($split)
->setGuiding($guiding)
->setBusEscort($busEscort)
;
}