condition = new FamilyInsuranceActiveCondition(); } public function testAlwaysFalseForApplicant(): void { $applicant = new ParticipantDto(); $applicant->index = 0; $applicant->insurance = $this->createFamilyInsurance(); $bookingDto = new BookingDto(new Travel(), 1); $bookingDto->participants = [$applicant]; $result = $this->condition->evaluate($bookingDto, 0, []); $this->assertFalse($result, 'Applicant is never affected by their own family insurance selection'); } public function testTrueForDependentWhenApplicantHasFamilyInsurance(): void { $applicant = new ParticipantDto(); $applicant->index = 0; $applicant->insurance = $this->createFamilyInsurance(); $dependent = new ParticipantDto(); $dependent->index = 1; $bookingDto = new BookingDto(new Travel(), 1); $bookingDto->participants = [$applicant, $dependent]; $result = $this->condition->evaluate($bookingDto, 1, []); $this->assertTrue($result, 'Dependent insurance field must be hidden when applicant has family insurance'); } public function testFalseForDependentWhenApplicantHasNonFamilyInsurance(): void { $nonFamilyInsurance = new Insurance(); $nonFamilyInsurance->familyInsurance = false; $applicant = new ParticipantDto(); $applicant->index = 0; $applicant->insurance = $nonFamilyInsurance; $dependent = new ParticipantDto(); $dependent->index = 1; $bookingDto = new BookingDto(new Travel(), 1); $bookingDto->participants = [$applicant, $dependent]; $result = $this->condition->evaluate($bookingDto, 1, []); $this->assertFalse($result, 'Dependent should keep their own insurance choice for non-family insurance'); } public function testFalseForDependentWhenApplicantHasNoInsurance(): void { $applicant = new ParticipantDto(); $applicant->index = 0; $dependent = new ParticipantDto(); $dependent->index = 1; $bookingDto = new BookingDto(new Travel(), 1); $bookingDto->participants = [$applicant, $dependent]; $result = $this->condition->evaluate($bookingDto, 1, []); $this->assertFalse($result); } public function testGetDependentFieldsReturnsInsurance(): void { $result = $this->condition->getDependentFields(); $this->assertSame(['insurance'], $result); } public function testGetDescriptionReturnsString(): void { $result = $this->condition->getDescription(); $this->assertIsString($result); $this->assertStringContainsString('family insurance', $result); } private function createFamilyInsurance(): Insurance { $insurance = new Insurance(); $insurance->familyInsurance = true; return $insurance; } }