39 lines
1.7 KiB
PHP
39 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Enum;
|
|
|
|
use App\Enum\RoomType;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Pins the classification to TYPO3's RoomTypeResolver, which the website search filters on.
|
|
*/
|
|
class RoomTypeTest extends TestCase
|
|
{
|
|
/**
|
|
* @return iterable<string, array{?string, ?string, ?int, ?int, ?RoomType}>
|
|
*/
|
|
public static function rooms(): iterable
|
|
{
|
|
yield 'single room' => ['EZ', 'Einzelzimmer Dusche/WC', 1, 1, RoomType::ForOne];
|
|
yield 'double room' => ['DZ', 'Doppelzimmer', 2, 1, RoomType::ForTwo];
|
|
yield 'six-bed room' => ['6BZ', 'Sechsbettzimmer', 6, 4, RoomType::ForSix];
|
|
yield 'nine and more' => ['MBZ', 'Gruppenraum', 12, 8, RoomType::ForNinePlus];
|
|
yield 'shared bed by "Bett im"' => ['MBZET', 'Bett im Mehrbettzimmer Etagendusche/-WC', 1, 1, RoomType::WithOthers];
|
|
yield 'shared bed by "mit anderen"' => ['APP', 'Apartment mit anderen Kunden', 4, 1, RoomType::WithOthers];
|
|
yield 'marker in any case' => ['X', 'BETT IM LAGER', 1, 1, RoomType::WithOthers];
|
|
yield 'minPax when maxPax is missing' => ['DZ', 'Doppelzimmer', null, 2, RoomType::ForTwo];
|
|
yield 'no occupancy at all' => ['X', 'Unbekannt', 0, 0, RoomType::WithOthers];
|
|
yield 'baby row is no room' => ['Baby', 'Babypreis für 0-2 Jährige', 1, 1, null];
|
|
}
|
|
|
|
#[DataProvider('rooms')]
|
|
public function testClassifiesByCapacityWithTheSharedBedAndBabyExceptions(?string $code, ?string $label, ?int $maxPax, ?int $minPax, ?RoomType $expected): void
|
|
{
|
|
self::assertSame($expected, RoomType::classify($code, $label, $maxPax, $minPax));
|
|
}
|
|
}
|