feat: force booking status 'O' for selection id 1473
addresses #869d79q0r
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\BusProNet\Service\StatusRule;
|
||||
|
||||
use App\BusProNet\Model\CrmSelection;
|
||||
use App\BusProNet\Model\CrmSelectionGroup;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Service\StatusRule\Selection1473StatusRule;
|
||||
use App\Form\Model\BookingDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Selection1473StatusRuleTest extends TestCase
|
||||
{
|
||||
private Selection1473StatusRule $rule;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->rule = new Selection1473StatusRule();
|
||||
}
|
||||
|
||||
public function testEvaluatesTrueWhenSelection1473Exists(): void
|
||||
{
|
||||
$bookingDto = new BookingDto($this->createTravelWithSelectionIds([1473]), 1);
|
||||
|
||||
$this->assertTrue($this->rule->evaluate($bookingDto));
|
||||
}
|
||||
|
||||
public function testEvaluatesFalseWhenSelection1473DoesNotExist(): void
|
||||
{
|
||||
$bookingDto = new BookingDto($this->createTravelWithSelectionIds([2001]), 1);
|
||||
|
||||
$this->assertFalse($this->rule->evaluate($bookingDto));
|
||||
}
|
||||
|
||||
public function testReturnsStatusO(): void
|
||||
{
|
||||
$this->assertSame('O', $this->rule->getStatus());
|
||||
}
|
||||
|
||||
public function testReturnsPriority200(): void
|
||||
{
|
||||
$this->assertSame(200, $this->rule->getPriority());
|
||||
}
|
||||
|
||||
public function testReturnsDescription(): void
|
||||
{
|
||||
$this->assertSame('Assigns Option status when selection 1473 is present', $this->rule->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $selectionIds
|
||||
*/
|
||||
private function createTravelWithSelectionIds(array $selectionIds): Travel
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->id = 1;
|
||||
$travel->hotelId = 1;
|
||||
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2030-01-08');
|
||||
$travel->selectionGroups = [
|
||||
1 => $this->createSelectionGroup(1, $selectionIds),
|
||||
];
|
||||
|
||||
return $travel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $selectionIds
|
||||
*/
|
||||
private function createSelectionGroup(int $groupId, array $selectionIds): CrmSelectionGroup
|
||||
{
|
||||
$group = new CrmSelectionGroup();
|
||||
$group->id = $groupId;
|
||||
$group->selections = [];
|
||||
|
||||
foreach ($selectionIds as $selectionId) {
|
||||
$selection = new CrmSelection();
|
||||
$selection->id = $selectionId;
|
||||
$group->selections[] = $selection;
|
||||
}
|
||||
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user