feat: cap rooms sharing a contingent per booking
This commit is contained in:
1 parent
5942ecf340
commit
3d94505e8d
18 files changed
+671
-19
No files matched your search
@@ -11,9 +11,11 @@ use App\BusProNet\Service\BookingStatusRuleRegistry;
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Model\RoomContingentPool;
|
||||
use App\Service\BookingConfigurator;
|
||||
use App\Service\BookingSessionManager;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use App\Service\RoomContingentPoolResolver;
|
||||
use App\Service\TravelDataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -162,14 +164,61 @@ class BookingConfiguratorRoomReconciliationTest extends TestCase
|
||||
$this->assertSame([], $bookingDto->roomSelections);
|
||||
}
|
||||
|
||||
private function bookingService(): BookingConfigurator
|
||||
public function testCapsRoomsSharingAContingentTogetherInSelectionOrder(): void
|
||||
{
|
||||
$eight = $this->createRoom(2366, '8er App mit 8 Personen', available: 1, minPax: 8);
|
||||
$seven = $this->createRoom(2367, '8er App mit 7 Personen', available: 1, minPax: 7);
|
||||
$travel = $this->createTravel([$eight, $seven]);
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [
|
||||
2366 => $this->createRoomSelection(2366, quantity: 1),
|
||||
2367 => $this->createRoomSelection(2367, quantity: 1),
|
||||
];
|
||||
|
||||
$adjustments = $this->bookingService([new RoomContingentPool([2366 => $eight, 2367 => $seven])])
|
||||
->reconcileRoomSelections($bookingDto);
|
||||
|
||||
$this->assertCount(1, $adjustments);
|
||||
$this->assertSame(2367, $adjustments[0]->roomId);
|
||||
$this->assertTrue($adjustments[0]->isDropped());
|
||||
$this->assertSame(1, $bookingDto->roomSelections[2366]->quantity);
|
||||
$this->assertSame(0, $bookingDto->roomSelections[2367]->quantity);
|
||||
}
|
||||
|
||||
public function testLeavesRoomsSharingAContingentAloneWhileTheyFit(): void
|
||||
{
|
||||
$eight = $this->createRoom(2366, '8er App mit 8 Personen', available: 2, minPax: 8);
|
||||
$seven = $this->createRoom(2367, '8er App mit 7 Personen', available: 2, minPax: 7);
|
||||
$travel = $this->createTravel([$eight, $seven]);
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [
|
||||
2366 => $this->createRoomSelection(2366, quantity: 1),
|
||||
2367 => $this->createRoomSelection(2367, quantity: 1),
|
||||
];
|
||||
|
||||
$adjustments = $this->bookingService([new RoomContingentPool([2366 => $eight, 2367 => $seven])])
|
||||
->reconcileRoomSelections($bookingDto);
|
||||
|
||||
$this->assertSame([], $adjustments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<RoomContingentPool> $sharedPools
|
||||
*/
|
||||
private function bookingService(array $sharedPools = []): BookingConfigurator
|
||||
{
|
||||
$poolResolver = $this->createStub(RoomContingentPoolResolver::class);
|
||||
$poolResolver->method('findSharedPools')->willReturn($sharedPools);
|
||||
|
||||
return new BookingConfigurator(
|
||||
$this->createStub(BookingSessionManager::class),
|
||||
$this->createStub(TravelDataProvider::class),
|
||||
$this->createStub(ParticipantEligibilityChecker::class),
|
||||
$this->createStub(BookingStatusRuleRegistry::class),
|
||||
$this->createStub(AgencyLoader::class),
|
||||
$poolResolver,
|
||||
'F'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user