fix: restore room occupancy lost to case-sensitive xml attribute lookup
This commit is contained in:
@@ -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]];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user