fix: restore room occupancy lost to case-sensitive xml attribute lookup
This commit is contained in:
@@ -70,6 +70,23 @@ class BookingSummaryAssemblerTest extends TestCase
|
||||
$this->assertSame(2, $summary->participantCount);
|
||||
}
|
||||
|
||||
public function testCreateStep1CountsRoomsWithUnknownOccupancyAsZero(): void
|
||||
{
|
||||
$service = $this->createService();
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$bookingDto->travel->rooms[12] = $this->createRoom(12, null);
|
||||
$bookingDto->currentStep = 1;
|
||||
$bookingDto->roomSelections = [
|
||||
$this->createRoomSelection(10, 1),
|
||||
$this->createRoomSelection(12, 2),
|
||||
];
|
||||
|
||||
$summary = $service->getSummaryData($bookingDto);
|
||||
|
||||
// 1×2 for the known room; the room without occupancy contributes nothing.
|
||||
$this->assertSame(2, $summary->participantCount);
|
||||
}
|
||||
|
||||
private function createService(): BookingSummaryAssembler
|
||||
{
|
||||
$priceCalculator = $this->createStub(BookingPriceCalculator::class);
|
||||
@@ -107,7 +124,7 @@ class BookingSummaryAssemblerTest extends TestCase
|
||||
return new BookingDto($travel, 157047);
|
||||
}
|
||||
|
||||
private function createRoom(int $id, int $maxPax): Room
|
||||
private function createRoom(int $id, ?int $maxPax): Room
|
||||
{
|
||||
$room = new Room();
|
||||
$room->id = $id;
|
||||
|
||||
@@ -272,6 +272,32 @@ class RoomAssignerTest extends TestCase
|
||||
self::assertNull($bookingDto->participants[1]->assignedRoomId);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function assignParticipantsToRoomsFallsBackToOneBedWhenOccupancyIsUnknown(): void
|
||||
{
|
||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||
['roomId' => 100, 'quantity' => 2, 'capacity' => 1],
|
||||
]);
|
||||
|
||||
$bookingDto->participants = [
|
||||
new ParticipantDto(),
|
||||
new ParticipantDto(),
|
||||
];
|
||||
|
||||
$room = new Room();
|
||||
$room->id = 100;
|
||||
$room->minPax = null;
|
||||
$room->available = 10;
|
||||
$room->status = Constants::STATUS_AVAILABLE;
|
||||
|
||||
$bookingDto->travel->rooms = [$room];
|
||||
|
||||
$this->service->assignParticipantsToRooms($bookingDto);
|
||||
|
||||
self::assertSame(100, $bookingDto->participants[0]->assignedRoomId);
|
||||
self::assertSame(100, $bookingDto->participants[1]->assignedRoomId);
|
||||
}
|
||||
|
||||
private function createBookingDtoWithRoomSelections(array $selections): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
|
||||
@@ -247,6 +247,31 @@ class RoomPricingCalculatorTest extends TestCase
|
||||
$this->assertEquals(458.0, $result[0]['totalPrice']);
|
||||
}
|
||||
|
||||
public function testCalculateRoomPricingFallsBackToOneParticipantWhenOccupancyIsUnknown(): void
|
||||
{
|
||||
$room = new Room();
|
||||
$room->id = 4;
|
||||
$room->price = 419.0;
|
||||
$room->minPax = null;
|
||||
$room->label = 'Bett im Mehrbettzimmer';
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->rooms = [$room];
|
||||
|
||||
$roomSelection = new RoomSelectionDto();
|
||||
$roomSelection->id = 4;
|
||||
$roomSelection->quantity = 2;
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->roomSelections = [$roomSelection];
|
||||
|
||||
$result = $this->calculator->calculateRoomPricing($bookingDto, RoomPricingCalculator::PRICING_MODE_SELECTION);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertEquals(2, $result[0]['participantCount']);
|
||||
$this->assertEquals(838.0, $result[0]['totalPrice']);
|
||||
}
|
||||
|
||||
public function testCalculateRoomPricingInEditModeUsesStoredIndividualPrices(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
|
||||
Reference in New Issue
Block a user