fix: reconcile assigned family insurance rate on updated participant

This commit is contained in:
Björn Fromme
2026-08-05 15:11:48 +02:00
parent 8a46908856
commit 0b642dcfe4
11 changed files with 723 additions and 8 deletions
+50 -1
View File
@@ -728,6 +728,54 @@ class ParticipantEditDtoTest extends TestCase
$this->assertCount(1, $insuranceViolations);
}
public function testDependentWithoutInsurancePassesWhenApplicantHasFamilyInsurance(): void
{
$applicant = $this->createAdultParticipant('[email protected]');
$applicant->insurance = $this->createMockInsurance(familyInsurance: true);
$dependent = $this->createAdultParticipant('[email protected]');
$dependent->insurance = null;
$bookingDto = $this->createBookingDtoWithParticipants([$applicant, $dependent]);
$wrapper = new ParticipantEditDto(
participant: $bookingDto->participants[1],
bookingContext: $bookingDto,
);
$violations = $this->validator->validate($wrapper, null, ['strict_required']);
$insuranceViolations = array_filter(
iterator_to_array($violations),
fn ($v) => 'participant.insurance' === $v->getPropertyPath()
);
$this->assertCount(0, $insuranceViolations);
}
public function testDependentWithoutInsuranceFailsWhenApplicantHasNonFamilyInsurance(): void
{
$applicant = $this->createAdultParticipant('[email protected]');
$applicant->insurance = $this->createMockInsurance(familyInsurance: false);
$dependent = $this->createAdultParticipant('[email protected]');
$dependent->insurance = null;
$bookingDto = $this->createBookingDtoWithParticipants([$applicant, $dependent]);
$wrapper = new ParticipantEditDto(
participant: $bookingDto->participants[1],
bookingContext: $bookingDto,
);
$violations = $this->validator->validate($wrapper, null, ['strict_required']);
$insuranceViolations = array_filter(
iterator_to_array($violations),
fn ($v) => 'participant.insurance' === $v->getPropertyPath()
);
$this->assertCount(1, $insuranceViolations);
}
private function createBookingDtoWithParticipants(array $participants): BookingDto
{
$travel = new Travel();
@@ -821,12 +869,13 @@ class ParticipantEditDtoTest extends TestCase
return $service;
}
private function createMockInsurance(): Insurance
private function createMockInsurance(bool $familyInsurance = false): Insurance
{
$insurance = new Insurance();
$insurance->id = '1';
$insurance->label = 'Test Insurance';
$insurance->price = 10.0;
$insurance->familyInsurance = $familyInsurance;
return $insurance;
}