44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Service;
|
|
|
|
use App\BusProNet\Model\Room;
|
|
use App\Service\BookingRoomSelectionService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class BookingRoomSelectionServiceTest extends TestCase
|
|
{
|
|
private BookingRoomSelectionService $service;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->service = new BookingRoomSelectionService();
|
|
}
|
|
|
|
public function testGroupRoomsBySelectionTypeSplitsAndSortsRooms(): void
|
|
{
|
|
$rooms = [
|
|
10 => $this->createRoom(10, '2 Bett Zimmer', 4),
|
|
11 => $this->createRoom(11, 'Suite', 2),
|
|
12 => $this->createRoom(12, '3 Bett Zimmer', 6),
|
|
];
|
|
|
|
$groups = $this->service->groupRoomsBySelectionType($rooms);
|
|
|
|
$this->assertSame([10, 12], array_keys($groups[Room::SELECTION_TYPE_BY_PAX]));
|
|
$this->assertSame([11], array_keys($groups[Room::SELECTION_TYPE_BY_ROOM]));
|
|
}
|
|
|
|
private function createRoom(int $id, string $label, int $maxPax): Room
|
|
{
|
|
$room = new Room();
|
|
$room->id = $id;
|
|
$room->label = $label;
|
|
$room->maxPax = $maxPax;
|
|
|
|
return $room;
|
|
}
|
|
}
|