feat: replace dropdowns with individual fields for body dimensions

This commit is contained in:
Björn Fromme
2026-05-28 13:59:30 +02:00
parent fa7e5c2091
commit bdf8cffd04
8 changed files with 366 additions and 148 deletions
+24 -19
View File
@@ -11,7 +11,6 @@ use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Service\ParticipantFormSupport;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class ParticipantFormSupportTest extends TestCase
{
@@ -61,34 +60,40 @@ class ParticipantFormSupportTest extends TestCase
public function testGetParticipantFormOptionsIncludesValidationToggle(): void
{
$parameterBag = $this->createMock(ParameterBagInterface::class);
$parameterBag->expects($this->exactly(4))
->method('get')
->willReturnMap([
['body_dimensions.height_choices', ['bis 148cm' => '-148']],
['body_dimensions.weight_choices', ['42 - 48kg' => '42-48']],
['body_dimensions.shoe_size_min', 36],
['body_dimensions.shoe_size_max', 48],
]);
$bodyDimensionRanges = [
'height_min' => 145,
'height_max' => 210,
'weight_min' => 40,
'weight_max' => 120,
'shoe_size_min' => 35,
'shoe_size_max' => 50,
];
$service = $this->createService(parameterBag: $parameterBag);
$service = $this->createService(bodyDimensionRanges: $bodyDimensionRanges);
$bookingDto = $this->createBookingDto();
$options = $service->getParticipantFormOptions($bookingDto, true);
$this->assertSame($bookingDto, $options['booking_context']);
$this->assertSame(['bis 148cm' => '-148'], $options['height_choices']);
$this->assertSame(['42 - 48kg' => '42-48'], $options['weight_choices']);
$this->assertSame(36, $options['shoe_size_min']);
$this->assertSame(48, $options['shoe_size_max']);
$this->assertFalse($options['validation_groups']);
$this->assertSame($bodyDimensionRanges, $options['body_dimension_ranges']);
$this->assertContains('validation_groups', array_keys($options));
}
private function createService(?ParameterBagInterface $parameterBag = null): ParticipantFormSupport
/**
* array<string, int>|null $bodyDimensionRanges
*/
private function createService(?array $bodyDimensionRanges = null): ParticipantFormSupport
{
$parameterBag ??= $this->createMock(ParameterBagInterface::class);
$bodyDimensionRanges ??= [
'height_min' => 145,
'height_max' => 210,
'weight_min' => 40,
'weight_max' => 120,
'shoe_size_min' => 35,
'shoe_size_max' => 50,
];
return new ParticipantFormSupport($parameterBag);
return new ParticipantFormSupport($bodyDimensionRanges);
}
private function createBookingDto(): BookingDto