parser = new InsuranceParser();
}
public function testParseIndividualInsuranceWithSubtype(): void
{
$xmlContent = '
';
$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 = '
';
$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 = '
';
$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 = '
';
$crawler = new Crawler($xmlContent);
$insurances = $this->parser->parse($crawler);
$this->assertEmpty($insurances);
}
public function testParseZusatzversicherungFiltering(): void
{
$xmlContent = '
';
$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);
}
}