service = new BookingParticipantCountService(); } public function testEnsureCorrectNumberOfParticipantsExpandsToCalculatedCount(): void { $travel = $this->createTravel([ 1 => 2, 2 => 3, ]); $bookingDto = new BookingDto($travel, 123); $bookingDto->roomSelections = [ $this->createRoomSelection(1, 1), $this->createRoomSelection(2, 2), ]; $bookingDto->participants = [new ParticipantDto()]; $this->service->ensureCorrectNumberOfParticipants($bookingDto); $this->assertCount(8, $bookingDto->participants); $this->assertSame(0, $bookingDto->participants[0]->index); $this->assertSame(7, $bookingDto->participants[7]->index); } private function createTravel(array $roomCapacities): Travel { $travel = new Travel(); $travel->dateFrom = new \DateTimeImmutable('2030-01-01'); $travel->dateTo = new \DateTimeImmutable('2030-01-06'); $rooms = []; foreach ($roomCapacities as $id => $minPax) { $room = new Room(); $room->id = $id; $room->label = 'Room '.$id; $room->minPax = $minPax; $room->maxPax = $minPax + 1; $room->available = 5; $room->status = Constants::STATUS_AVAILABLE; $rooms[$id] = $room; } $travel->rooms = $rooms; return $travel; } private function createRoomSelection(int $id, int $quantity): RoomSelectionDto { $selection = new RoomSelectionDto(); $selection->id = $id; $selection->quantity = $quantity; return $selection; } }