feat: disable body dimensions validation for selection id 1475
closes #869dne7qt
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user