feat: offer rooms on request by Anf code suffix

This commit is contained in:
fromme committed 2026-11-11 11:35:38 +01:00
1 parent 2936d8947a
commit 0b0286787b
11 files changed
+204 -41

No files matched your search

+16 -10
View File
@@ -12,22 +12,28 @@ use PHPUnit\Framework\TestCase;
class RoomTest extends TestCase
{
#[DataProvider('bookableStateProvider')]
public function testIsBookableState(?string $status, ?int $available, bool $expected): void
public function testIsBookableState(?string $status, ?int $available, ?string $code, bool $expected): void
{
self::assertSame($expected, Room::isBookableState($status, $available));
self::assertSame($expected, Room::isBookableState($status, $available, $code));
}
/**
* @return iterable<string, array{?string, ?int, bool}>
* @return iterable<string, array{?string, ?int, ?string, bool}>
*/
public static function bookableStateProvider(): iterable
{
yield 'free with rooms left' => [Constants::STATUS_AVAILABLE, 3, true];
yield 'free but sold out' => [Constants::STATUS_AVAILABLE, 0, false];
yield 'free without a count' => [Constants::STATUS_AVAILABLE, null, false];
yield 'on request with rooms left' => [Constants::STATUS_ON_REQUEST, 5, false];
yield 'on request and sold out' => [Constants::STATUS_ON_REQUEST, 0, false];
yield 'booking stop' => [Constants::STATUS_BLOCKED, 5, false];
yield 'no status' => [null, 5, false];
yield 'free with rooms left' => [Constants::STATUS_AVAILABLE, 3, '2erDW', true];
yield 'free but sold out' => [Constants::STATUS_AVAILABLE, 0, '2erDW', false];
yield 'free without a count' => [Constants::STATUS_AVAILABLE, null, '2erDW', false];
yield 'free with the on-request suffix' => [Constants::STATUS_AVAILABLE, 3, '6erSDAnf', true];
yield 'on request with rooms left' => [Constants::STATUS_ON_REQUEST, 5, '2erDW', false];
yield 'on request and sold out' => [Constants::STATUS_ON_REQUEST, 0, '2erDW', false];
yield 'on request without a code' => [Constants::STATUS_ON_REQUEST, 5, null, false];
yield 'on request by code with rooms left' => [Constants::STATUS_ON_REQUEST, 1, '6erSDAnf', true];
yield 'on request by code and sold out' => [Constants::STATUS_ON_REQUEST, 0, '6erSDAnf', false];
yield 'on request, marker not a suffix' => [Constants::STATUS_ON_REQUEST, 1, 'Anf6erSD', false];
yield 'on request, marker in another case' => [Constants::STATUS_ON_REQUEST, 1, '6erSDANF', false];
yield 'booking stop with the on-request suffix' => [Constants::STATUS_BLOCKED, 5, '6erSDAnf', false];
yield 'no status' => [null, 5, '2erDW', false];
}
}