feat: disable body dimensions validation for selection id 1475

closes #869dne7qt
This commit is contained in:
Björn Fromme
2026-06-12 11:39:32 +02:00
parent b2fccae431
commit 93201fbd20
4 changed files with 217 additions and 4 deletions
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace App\Tests\Validator;
use App\BusProNet\Model\CrmSelection;
use App\BusProNet\Model\CrmSelectionGroup;
use App\BusProNet\Model\Travel;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Form\Model\ParticipantEditDto;
use App\Validator\SelectionBasedBodyDimensionExemption;
use PHPUnit\Framework\TestCase;
class SelectionBasedBodyDimensionExemptionTest extends TestCase
{
private SelectionBasedBodyDimensionExemption $exemption;
protected function setUp(): void
{
$this->exemption = new SelectionBasedBodyDimensionExemption();
}
public function testReturnsTrueWhenWrapperTravelContainsSelection1474(): void
{
$root = $this->createWrapperWithSelectionIds([1474]);
$this->assertTrue($this->exemption->isBodyDimensionValidationExempt($root));
}
public function testReturnsFalseWhenSelection1474IsAbsent(): void
{
$root = $this->createWrapperWithSelectionIds([2001]);
$this->assertFalse($this->exemption->isBodyDimensionValidationExempt($root));
}
public function testReturnsFalseWhenRootIsNotParticipantEditDto(): void
{
$this->assertFalse($this->exemption->isBodyDimensionValidationExempt(new \stdClass()));
}
private function createWrapperWithSelectionIds(array $selectionIds): ParticipantEditDto
{
$travel = new Travel();
$travel->selectionGroups = [
1 => $this->createSelectionGroup(1, $selectionIds),
];
$bookingDto = new BookingDto($travel, 1);
$participant = new ParticipantDto();
return new ParticipantEditDto(
participant: $participant,
bookingContext: $bookingDto,
);
}
/**
* @param list<int> $selectionIds
*/
private function createSelectionGroup(int $groupId, array $selectionIds): CrmSelectionGroup
{
$group = new CrmSelectionGroup();
$group->id = $groupId;
$group->selections = [];
foreach ($selectionIds as $selectionId) {
$selection = new CrmSelection();
$selection->id = $selectionId;
$group->selections[] = $selection;
}
return $group;
}
}