wip: insurance booking phases 1 and 2
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\BusProNet\XmlParser;
|
||||
|
||||
use App\BusProNet\XmlParser\InsuranceParser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class InsuranceParserTest extends TestCase
|
||||
{
|
||||
private InsuranceParser $parser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->parser = new InsuranceParser();
|
||||
}
|
||||
|
||||
public function testParseIndividualInsuranceWithSubtype(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<versicherungsstammdaten>
|
||||
<versicherungen>
|
||||
<versicherung id="1" idbuspro="178917" code="903100" bezeichnung="Reise-Rücktritt" preis="5,00" preisartprozent="False" unterart="RRV" familienversicherung="False" paarversicherung="False" zusatzversicherung="False" reisedatumvon="01.09.2024" reisedatumbis="31.12.2030" buchungdatumvon="01.03.2025" buchungdatumbis="31.12.2030" altervon="0" alterbis="64" reisepreisvon="0,00" reisepreisbis="100,00" reisedauervon="0" reisedauerbis="255" />
|
||||
<versicherung id="2" idbuspro="177236" code="913320" bezeichnung="Reiseschutz Platin Auto/Bahn/Bus (Europa)" preis="9,00" preisartprozent="False" unterart="PAK" familienversicherung="True" paarversicherung="False" zusatzversicherung="False" reisedatumvon="01.09.2024" reisedatumbis="31.12.2030" buchungdatumvon="01.03.2025" buchungdatumbis="31.12.2030" altervon="0" alterbis="64" reisepreisvon="0,00" reisepreisbis="100,00" reisedauervon="1" reisedauerbis="45" />
|
||||
<versicherung id="3" idbuspro="177270" code="903551" bezeichnung="Selbstbehaltübernahme" preis="5,00" preisartprozent="False" unterart="OHN" familienversicherung="False" paarversicherung="False" zusatzversicherung="True" reisedatumvon="01.09.2024" reisedatumbis="31.12.2030" buchungdatumvon="01.03.2025" buchungdatumbis="31.12.2030" altervon="0" alterbis="64" reisepreisvon="0,00" reisepreisbis="600,00" reisedauervon="0" reisedauerbis="255" />
|
||||
</versicherungen>
|
||||
<versicherungspakete>
|
||||
<versicherungspaket id="1" idbuspro="P1000320" bezeichnung="Reiseschutz Platin Auto/Bahn/Bus (Europa) + Selbstbehaltübernahme" preis="14,00" preisartprozent="False" reisedatumvon="01.09.2024" reisedatumbis="31.12.2030" altervon="0" alterbis="64" reisepreisvon="0" reisepreisbis="100,00" familienversicherung="False">
|
||||
<enthalteneversicherungen>
|
||||
<enthalteneversicherung idbuspro="177236" />
|
||||
<enthalteneversicherung idbuspro="177270" />
|
||||
</enthalteneversicherungen>
|
||||
</versicherungspaket>
|
||||
</versicherungspakete>
|
||||
</versicherungsstammdaten>';
|
||||
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$insurances = $this->parser->parse($crawler);
|
||||
|
||||
// Test individual insurances + package (3 individual + 1 package = 4 total)
|
||||
$this->assertCount(4, $insurances);
|
||||
|
||||
// Test travel cancellation insurance (RRV)
|
||||
$cancellationInsurance = $insurances[178917];
|
||||
$this->assertEquals(178917, $cancellationInsurance->id);
|
||||
$this->assertEquals('903100', $cancellationInsurance->code);
|
||||
$this->assertEquals('Reise-Rücktritt', $cancellationInsurance->label);
|
||||
$this->assertEquals('RRV', $cancellationInsurance->subType);
|
||||
$this->assertEquals(5.0, $cancellationInsurance->price);
|
||||
$this->assertFalse($cancellationInsurance->familyInsurance);
|
||||
$this->assertFalse($cancellationInsurance->package);
|
||||
|
||||
// Test travel protection insurance (PAK) with family flag
|
||||
$protectionInsurance = $insurances[177236];
|
||||
$this->assertEquals(177236, $protectionInsurance->id);
|
||||
$this->assertEquals('913320', $protectionInsurance->code);
|
||||
$this->assertEquals('Reiseschutz Platin Auto/Bahn/Bus (Europa)', $protectionInsurance->label);
|
||||
$this->assertEquals('PAK', $protectionInsurance->subType);
|
||||
$this->assertEquals(9.0, $protectionInsurance->price);
|
||||
$this->assertTrue($protectionInsurance->familyInsurance);
|
||||
$this->assertFalse($protectionInsurance->package);
|
||||
|
||||
// Test deductible insurance (OHN) - should be included because it's referenced by package
|
||||
$deductibleInsurance = $insurances[177270];
|
||||
$this->assertEquals(177270, $deductibleInsurance->id);
|
||||
$this->assertEquals('903551', $deductibleInsurance->code);
|
||||
$this->assertEquals('Selbstbehaltübernahme', $deductibleInsurance->label);
|
||||
$this->assertEquals('OHN', $deductibleInsurance->subType);
|
||||
$this->assertEquals(5.0, $deductibleInsurance->price);
|
||||
$this->assertFalse($deductibleInsurance->familyInsurance);
|
||||
$this->assertFalse($deductibleInsurance->package);
|
||||
|
||||
// Test package
|
||||
$package = $insurances['P1000320'];
|
||||
$this->assertEquals('P1000320', $package->id);
|
||||
$this->assertEquals('Reiseschutz Platin Auto/Bahn/Bus (Europa) + Selbstbehaltübernahme', $package->label);
|
||||
$this->assertNull($package->subType); // Packages don't have subtypes
|
||||
$this->assertEquals(14.0, $package->price);
|
||||
$this->assertFalse($package->familyInsurance);
|
||||
$this->assertTrue($package->package);
|
||||
$this->assertEquals([177236, 177270], $package->containedInsuranceIds);
|
||||
}
|
||||
|
||||
public function testParsePackageWithoutSubtype(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<versicherungsstammdaten>
|
||||
<versicherungen>
|
||||
<versicherung id="1" idbuspro="177236" code="913320" bezeichnung="Test Insurance" preis="9,00" preisartprozent="False" unterart="PAK" familienversicherung="False" paarversicherung="False" zusatzversicherung="False" />
|
||||
</versicherungen>
|
||||
<versicherungspakete>
|
||||
<versicherungspaket id="1" idbuspro="P1000320" bezeichnung="Test Package" preis="14,00" familienversicherung="True">
|
||||
<enthalteneversicherungen>
|
||||
<enthalteneversicherung idbuspro="177236" />
|
||||
</enthalteneversicherungen>
|
||||
</versicherungspaket>
|
||||
</versicherungspakete>
|
||||
</versicherungsstammdaten>';
|
||||
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$insurances = $this->parser->parse($crawler);
|
||||
|
||||
$this->assertCount(2, $insurances);
|
||||
|
||||
// Test package has no subType but has familyInsurance flag
|
||||
$package = $insurances['P1000320'];
|
||||
$this->assertEquals('P1000320', $package->id);
|
||||
$this->assertNull($package->subType);
|
||||
$this->assertTrue($package->familyInsurance);
|
||||
$this->assertTrue($package->package);
|
||||
}
|
||||
|
||||
public function testParseInsuranceWithNullSubtype(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<versicherungsstammdaten>
|
||||
<versicherungen>
|
||||
<versicherung id="1" idbuspro="178917" code="903100" bezeichnung="Test Insurance" preis="5,00" preisartprozent="False" familienversicherung="False" paarversicherung="False" zusatzversicherung="False" />
|
||||
</versicherungen>
|
||||
</versicherungsstammdaten>';
|
||||
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$insurances = $this->parser->parse($crawler);
|
||||
|
||||
$this->assertCount(1, $insurances);
|
||||
|
||||
$insurance = $insurances[178917];
|
||||
$this->assertEquals(178917, $insurance->id);
|
||||
$this->assertNull($insurance->subType); // Missing unterart attribute should result in null
|
||||
$this->assertFalse($insurance->package);
|
||||
}
|
||||
|
||||
public function testParseEmptyXml(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<versicherungsstammdaten>
|
||||
<versicherungen>
|
||||
</versicherungen>
|
||||
<versicherungspakete>
|
||||
</versicherungspakete>
|
||||
</versicherungsstammdaten>';
|
||||
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$insurances = $this->parser->parse($crawler);
|
||||
|
||||
$this->assertEmpty($insurances);
|
||||
}
|
||||
|
||||
public function testParseZusatzversicherungFiltering(): void
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<versicherungsstammdaten>
|
||||
<versicherungen>
|
||||
<versicherung id="1" idbuspro="178917" code="903100" bezeichnung="Normal Insurance" preis="5,00" preisartprozent="False" unterart="RRV" familienversicherung="False" paarversicherung="False" zusatzversicherung="False" />
|
||||
<versicherung id="2" idbuspro="177270" code="903551" bezeichnung="Zusatz Insurance Referenced" preis="5,00" preisartprozent="False" unterart="OHN" familienversicherung="False" paarversicherung="False" zusatzversicherung="True" />
|
||||
<versicherung id="3" idbuspro="999999" code="999999" bezeichnung="Zusatz Insurance Not Referenced" preis="5,00" preisartprozent="False" unterart="OHN" familienversicherung="False" paarversicherung="False" zusatzversicherung="True" />
|
||||
</versicherungen>
|
||||
<versicherungspakete>
|
||||
<versicherungspaket id="1" idbuspro="P1000320" bezeichnung="Test Package" preis="14,00" familienversicherung="False">
|
||||
<enthalteneversicherungen>
|
||||
<enthalteneversicherung idbuspro="177270" />
|
||||
</enthalteneversicherungen>
|
||||
</versicherungspaket>
|
||||
</versicherungspakete>
|
||||
</versicherungsstammdaten>';
|
||||
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$insurances = $this->parser->parse($crawler);
|
||||
|
||||
// Should include: normal insurance (178917), referenced zusatz (177270), and package (P1000320)
|
||||
// Should exclude: unreferenced zusatz (999999)
|
||||
$this->assertCount(3, $insurances);
|
||||
$this->assertArrayHasKey(178917, $insurances);
|
||||
$this->assertArrayHasKey(177270, $insurances);
|
||||
$this->assertArrayHasKey('P1000320', $insurances);
|
||||
$this->assertArrayNotHasKey(999999, $insurances);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Model;
|
||||
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantDtoTest extends TestCase
|
||||
{
|
||||
public function testGetAgeReturnsNullWhenDateOfBirthIsNull(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = null;
|
||||
|
||||
$this->assertNull($participant->getAge());
|
||||
}
|
||||
|
||||
public function testGetAgeCalculatesCurrentAgeWhenNoReferenceDateProvided(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
|
||||
$expectedAge = (new \DateTimeImmutable())->diff($participant->dateOfBirth)->y;
|
||||
$actualAge = $participant->getAge();
|
||||
|
||||
$this->assertEquals($expectedAge, $actualAge);
|
||||
}
|
||||
|
||||
public function testGetAgeCalculatesAgeAtSpecificReferenceDate(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
$referenceDate = new \DateTimeImmutable('2024-06-14'); // Day before 34th birthday
|
||||
|
||||
$result = $participant->getAge($referenceDate);
|
||||
|
||||
$this->assertEquals(33, $result); // Still 33 years old
|
||||
}
|
||||
|
||||
public function testGetAgeCalculatesAgeAtSpecificReferenceDateAfterBirthday(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
$referenceDate = new \DateTimeImmutable('2024-06-15'); // Exactly 34th birthday
|
||||
|
||||
$result = $participant->getAge($referenceDate);
|
||||
|
||||
$this->assertEquals(34, $result); // Now 34 years old
|
||||
}
|
||||
|
||||
public function testGetAgeCalculatesAgeForInsuranceEligibilityScenario(): void
|
||||
{
|
||||
// Travel starts on 2024-08-01, participant born 1989-12-25
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1989-12-25');
|
||||
$travelStartDate = new \DateTimeImmutable('2024-08-01');
|
||||
|
||||
$result = $participant->getAge($travelStartDate);
|
||||
|
||||
// On 2024-08-01, they are still 34 (birthday not yet reached)
|
||||
$this->assertEquals(34, $result);
|
||||
}
|
||||
|
||||
public function testGetAgeCalculatesAgeForInsuranceEligibilityScenarioAfterBirthday(): void
|
||||
{
|
||||
// Travel starts on 2024-12-26, participant born 1989-12-25
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1989-12-25');
|
||||
$travelStartDate = new \DateTimeImmutable('2024-12-26');
|
||||
|
||||
$result = $participant->getAge($travelStartDate);
|
||||
|
||||
// On 2024-12-26, they just turned 35
|
||||
$this->assertEquals(35, $result);
|
||||
}
|
||||
|
||||
public function testGetAgeHandlesLeapYearScenarios(): void
|
||||
{
|
||||
// Born on Feb 29, 2000 (leap year)
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('2000-02-29');
|
||||
$referenceDate = new \DateTimeImmutable('2023-02-28'); // Non-leap year
|
||||
|
||||
$result = $participant->getAge($referenceDate);
|
||||
|
||||
$this->assertEquals(22, $result); // Still 22, birthday is technically next day
|
||||
}
|
||||
|
||||
public function testGetAgeReturnsNullWithReferenceDateWhenDateOfBirthIsNull(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = null;
|
||||
$referenceDate = new \DateTimeImmutable('2024-08-01');
|
||||
|
||||
$result = $participant->getAge($referenceDate);
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
public function testGetAgeWithYoungParticipant(): void
|
||||
{
|
||||
// Child born in 2020
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('2020-03-15');
|
||||
$referenceDate = new \DateTimeImmutable('2024-08-01');
|
||||
|
||||
$result = $participant->getAge($referenceDate);
|
||||
|
||||
$this->assertEquals(4, $result);
|
||||
}
|
||||
|
||||
public function testGetAgeWithElderlyParticipant(): void
|
||||
{
|
||||
// Elderly participant born in 1940
|
||||
$participant = new ParticipantDto();
|
||||
$participant->dateOfBirth = new \DateTimeImmutable('1940-05-20');
|
||||
$referenceDate = new \DateTimeImmutable('2024-08-01');
|
||||
|
||||
$result = $participant->getAge($referenceDate);
|
||||
|
||||
$this->assertEquals(84, $result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\Service\InsuranceTypeResolver;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InsuranceTypeResolverTest extends TestCase
|
||||
{
|
||||
private InsuranceTypeResolver $resolver;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->resolver = new InsuranceTypeResolver();
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualTravelCancellationInsurance(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = 'RRV';
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_CANCELLATION, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualFamilyTravelCancellationInsurance(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = 'RRV';
|
||||
$insurance->familyInsurance = true;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_CANCELLATION_FAMILY, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualTravelProtectionInsurance(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = 'PAK';
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_PROTECTION, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualFamilyTravelProtectionInsurance(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = 'PAK';
|
||||
$insurance->familyInsurance = true;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_PROTECTION_FAMILY, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualDeductibleInsurance(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = 'OHN';
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::DEDUCTIBLE, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualUnknownSubtype(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = 'UNKNOWN';
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForIndividualNullSubtype(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->package = false;
|
||||
$insurance->subType = null;
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$result = $this->resolver->resolveType($insurance);
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForPackageWithTravelProtectionContent(): void
|
||||
{
|
||||
// Create contained insurances
|
||||
$protectionInsurance = new Insurance();
|
||||
$protectionInsurance->subType = 'PAK';
|
||||
|
||||
$deductibleInsurance = new Insurance();
|
||||
$deductibleInsurance->subType = 'OHN';
|
||||
|
||||
// Create package
|
||||
$package = new Insurance();
|
||||
$package->package = true;
|
||||
$package->familyInsurance = false;
|
||||
$package->containedInsurances = [$protectionInsurance, $deductibleInsurance];
|
||||
|
||||
$result = $this->resolver->resolveType($package);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_PROTECTION, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForFamilyPackageWithTravelProtectionContent(): void
|
||||
{
|
||||
// Create contained insurances
|
||||
$protectionInsurance = new Insurance();
|
||||
$protectionInsurance->subType = 'PAK';
|
||||
|
||||
$deductibleInsurance = new Insurance();
|
||||
$deductibleInsurance->subType = 'OHN';
|
||||
|
||||
// Create family package
|
||||
$package = new Insurance();
|
||||
$package->package = true;
|
||||
$package->familyInsurance = true;
|
||||
$package->containedInsurances = [$protectionInsurance, $deductibleInsurance];
|
||||
|
||||
$result = $this->resolver->resolveType($package);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_PROTECTION_FAMILY, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForPackageWithTravelCancellationContent(): void
|
||||
{
|
||||
// Create contained insurances
|
||||
$cancellationInsurance = new Insurance();
|
||||
$cancellationInsurance->subType = 'RRV';
|
||||
|
||||
$deductibleInsurance = new Insurance();
|
||||
$deductibleInsurance->subType = 'OHN';
|
||||
|
||||
// Create package
|
||||
$package = new Insurance();
|
||||
$package->package = true;
|
||||
$package->familyInsurance = false;
|
||||
$package->containedInsurances = [$cancellationInsurance, $deductibleInsurance];
|
||||
|
||||
$result = $this->resolver->resolveType($package);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_CANCELLATION, $result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForPackageWithOnlyDeductibleContent(): void
|
||||
{
|
||||
// Create contained insurance (only deductible)
|
||||
$deductibleInsurance = new Insurance();
|
||||
$deductibleInsurance->subType = 'OHN';
|
||||
|
||||
// Create package
|
||||
$package = new Insurance();
|
||||
$package->package = true;
|
||||
$package->familyInsurance = false;
|
||||
$package->containedInsurances = [$deductibleInsurance];
|
||||
|
||||
$result = $this->resolver->resolveType($package);
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForPackageWithNoContainedInsurances(): void
|
||||
{
|
||||
$package = new Insurance();
|
||||
$package->package = true;
|
||||
$package->familyInsurance = false;
|
||||
$package->containedInsurances = [];
|
||||
|
||||
$result = $this->resolver->resolveType($package);
|
||||
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
public function testResolveTypeForPackageWithMultiplePrimaryTypes(): void
|
||||
{
|
||||
// Create contained insurances with multiple primary types
|
||||
$protectionInsurance = new Insurance();
|
||||
$protectionInsurance->subType = 'PAK';
|
||||
|
||||
$cancellationInsurance = new Insurance();
|
||||
$cancellationInsurance->subType = 'RRV';
|
||||
|
||||
// Create package - should return first non-deductible type found
|
||||
$package = new Insurance();
|
||||
$package->package = true;
|
||||
$package->familyInsurance = false;
|
||||
$package->containedInsurances = [$protectionInsurance, $cancellationInsurance];
|
||||
|
||||
$result = $this->resolver->resolveType($package);
|
||||
|
||||
$this->assertEquals(InsuranceTypeResolver::TRAVEL_PROTECTION, $result);
|
||||
}
|
||||
|
||||
public function testGetAllTypes(): void
|
||||
{
|
||||
$types = $this->resolver->getAllTypes();
|
||||
|
||||
$expectedTypes = [
|
||||
InsuranceTypeResolver::TRAVEL_CANCELLATION,
|
||||
InsuranceTypeResolver::TRAVEL_CANCELLATION_FAMILY,
|
||||
InsuranceTypeResolver::TRAVEL_PROTECTION,
|
||||
InsuranceTypeResolver::TRAVEL_PROTECTION_FAMILY,
|
||||
InsuranceTypeResolver::DEDUCTIBLE,
|
||||
];
|
||||
|
||||
$this->assertEquals($expectedTypes, $types);
|
||||
$this->assertCount(5, $types);
|
||||
}
|
||||
|
||||
public function testIsFamilyType(): void
|
||||
{
|
||||
$this->assertTrue($this->resolver->isFamilyType(InsuranceTypeResolver::TRAVEL_CANCELLATION_FAMILY));
|
||||
$this->assertTrue($this->resolver->isFamilyType(InsuranceTypeResolver::TRAVEL_PROTECTION_FAMILY));
|
||||
$this->assertFalse($this->resolver->isFamilyType(InsuranceTypeResolver::TRAVEL_CANCELLATION));
|
||||
$this->assertFalse($this->resolver->isFamilyType(InsuranceTypeResolver::TRAVEL_PROTECTION));
|
||||
$this->assertFalse($this->resolver->isFamilyType(InsuranceTypeResolver::DEDUCTIBLE));
|
||||
}
|
||||
|
||||
public function testGetBaseType(): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
InsuranceTypeResolver::TRAVEL_CANCELLATION,
|
||||
$this->resolver->getBaseType(InsuranceTypeResolver::TRAVEL_CANCELLATION_FAMILY)
|
||||
);
|
||||
$this->assertEquals(
|
||||
InsuranceTypeResolver::TRAVEL_PROTECTION,
|
||||
$this->resolver->getBaseType(InsuranceTypeResolver::TRAVEL_PROTECTION_FAMILY)
|
||||
);
|
||||
$this->assertEquals(
|
||||
InsuranceTypeResolver::TRAVEL_CANCELLATION,
|
||||
$this->resolver->getBaseType(InsuranceTypeResolver::TRAVEL_CANCELLATION)
|
||||
);
|
||||
$this->assertEquals(
|
||||
InsuranceTypeResolver::DEDUCTIBLE,
|
||||
$this->resolver->getBaseType(InsuranceTypeResolver::DEDUCTIBLE)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user