fix: incorrect rules around family insurances
addresses #869dr80qj
This commit is contained in:
@@ -252,4 +252,86 @@ class BookingPriceCalculatorTest extends TestCase
|
||||
'calculateServiceTotal() must agree with the display breakdown on bulk-insurance bookings'
|
||||
);
|
||||
}
|
||||
|
||||
public function testResolveInsuranceTravelPriceUsesIndividualPriceForNonFamilyInsurance(): void
|
||||
{
|
||||
$skiPass = new Service();
|
||||
$skiPass->price = 50.0;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->skiPass = $skiPass;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$nonFamilyInsurance = new Insurance();
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$result = $this->service->resolveInsuranceTravelPrice($bookingDto, 0, $nonFamilyInsurance);
|
||||
|
||||
$this->assertEquals(50.0, $result);
|
||||
}
|
||||
|
||||
public function testResolveInsuranceTravelPriceUsesTotalPriceForFamilyInsuranceOnApplicant(): void
|
||||
{
|
||||
$applicantSkiPass = new Service();
|
||||
$applicantSkiPass->price = 50.0;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->skiPass = $applicantSkiPass;
|
||||
|
||||
$dependentSkiPass = new Service();
|
||||
$dependentSkiPass->price = 30.0;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
$dependent->skiPass = $dependentSkiPass;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$result = $this->service->resolveInsuranceTravelPrice($bookingDto, 0, $familyInsurance);
|
||||
|
||||
$this->assertEquals(80.0, $result);
|
||||
}
|
||||
|
||||
public function testResolveInsuranceTravelPriceUsesTotalPriceForFamilyInsuranceRegardlessOfParticipantIndex(): void
|
||||
{
|
||||
// Family insurances are restricted to the applicant by InsuranceManager's eligibility
|
||||
// constraints, not by this method - it always resolves the total price for them.
|
||||
$applicantSkiPass = new Service();
|
||||
$applicantSkiPass->price = 50.0;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->skiPass = $applicantSkiPass;
|
||||
|
||||
$dependentSkiPass = new Service();
|
||||
$dependentSkiPass->price = 30.0;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
$dependent->skiPass = $dependentSkiPass;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$result = $this->service->resolveInsuranceTravelPrice($bookingDto, 1, $familyInsurance);
|
||||
|
||||
$this->assertEquals(80.0, $result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user