fix: restore room occupancy lost to case-sensitive xml attribute lookup

This commit is contained in:
Björn Fromme
2026-08-31 14:15:21 +02:00
parent 24df764efb
commit e14d29f7d4
10 changed files with 223 additions and 16 deletions
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Tests\Form;
use App\Form\Model\RoomSelectionDto;
use App\Form\RoomSelectType;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Forms;
class RoomSelectTypeTest extends TestCase
{
/**
* @param array<string, int> $expectedChoices
*/
#[DataProvider('quantityChoiceProvider')]
public function testQuantityChoicesFollowAvailability(int $maxQuantity, array $expectedChoices): void
{
$data = new RoomSelectionDto();
$data->id = 95;
$data->maxQuantity = $maxQuantity;
$form = Forms::createFormFactory()->create(RoomSelectType::class, $data);
$this->assertSame($expectedChoices, $form->get('quantity')->getConfig()->getOption('choices'));
}
/**
* @return iterable<string, array{int, array<string, int>}>
*/
public static function quantityChoiceProvider(): iterable
{
yield 'available rooms are selectable' => [2, ['-' => 0, '1' => 1, '2' => 2]];
// range(1, 0) would return [1, 0], offering a bookable "1" for a room with no availability.
yield 'no availability offers only the placeholder' => [0, ['-' => 0]];
}
}