feat: force booking status 'O' for selection id 1473
addresses #869d79q0r
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App\Tests\BusProNet\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Service\BookingStatusRuleRegistry;
|
||||
use App\BusProNet\Service\Contract\BookingStatusRuleInterface;
|
||||
use App\BusProNet\Service\StatusRule\Selection1473StatusRule;
|
||||
use App\Form\Model\BookingDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -99,6 +100,22 @@ class BookingStatusRuleRegistryTest extends TestCase
|
||||
$this->assertSame('L', $registry->evaluateStatus($bookingDto));
|
||||
}
|
||||
|
||||
public function testSelection1473RuleWinsOverLowerPriorityRule(): void
|
||||
{
|
||||
$lowerPriorityRule = $this->createMock(BookingStatusRuleInterface::class);
|
||||
$lowerPriorityRule->method('evaluate')->willReturn(true);
|
||||
$lowerPriorityRule->method('getStatus')->willReturn('X');
|
||||
$lowerPriorityRule->method('getPriority')->willReturn(100);
|
||||
|
||||
$registry = new BookingStatusRuleRegistry([
|
||||
$lowerPriorityRule,
|
||||
new Selection1473StatusRule(),
|
||||
]);
|
||||
$bookingDto = new BookingDto($this->createMockTravelWithSelection1473(), 1);
|
||||
|
||||
$this->assertSame('O', $registry->evaluateStatus($bookingDto));
|
||||
}
|
||||
|
||||
private function createMockTravel(): Travel
|
||||
{
|
||||
$travel = new Travel();
|
||||
@@ -109,4 +126,32 @@ class BookingStatusRuleRegistryTest extends TestCase
|
||||
|
||||
return $travel;
|
||||
}
|
||||
|
||||
private function createMockTravelWithSelection1473(): Travel
|
||||
{
|
||||
$travel = $this->createMockTravel();
|
||||
$travel->selectionGroups = [
|
||||
1 => $this->createSelectionGroup(1, [1473]),
|
||||
];
|
||||
|
||||
return $travel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $selectionIds
|
||||
*/
|
||||
private function createSelectionGroup(int $groupId, array $selectionIds): \App\BusProNet\Model\CrmSelectionGroup
|
||||
{
|
||||
$group = new \App\BusProNet\Model\CrmSelectionGroup();
|
||||
$group->id = $groupId;
|
||||
$group->selections = [];
|
||||
|
||||
foreach ($selectionIds as $selectionId) {
|
||||
$selection = new \App\BusProNet\Model\CrmSelection();
|
||||
$selection->id = $selectionId;
|
||||
$group->selections[] = $selection;
|
||||
}
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user