fix: allow hotel-less travel data

addresses #869ckkwh7
This commit is contained in:
Björn Fromme
2026-03-23 16:59:49 +01:00
parent 502281e219
commit ccfafc5da4
4 changed files with 87 additions and 5 deletions
@@ -184,6 +184,49 @@ class TravelParserTest extends TestCase
$this->assertTrue($additionalServices[183660]->autoBook);
}
public function testParseTravelWithoutHotelNode(): void
{
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
<reisen>
<reise id="1" idbuspro="2293" code="">
<termin id="1" idbuspro="12162" idprodukt="2293" termin="28.03.2026" bis="04.04.2026" code="PGTSGI280326" reiseart="P">
<text>PG TSG Irlich</text>
<abpreis>-50,00</abpreis>
<lei_sonstiges>
<leistung id="1" idbuspro="188858" unterart="SON" termin="28.03.2026" bis="04.04.2026" automatisch_buchen="False" pflicht="False">
<text>7 Übernachtungen im 3* Posthotel</text>
<preis>999,00</preis>
<status>Frei</status>
</leistung>
</lei_sonstiges>
<lei_befoerderung>
<leistung id="1" idbuspro="188850" unterart="BUS" termin="27.03.2026" bis="28.03.2026" automatisch_buchen="False" pflicht="False">
<text>Bus-Hinfahrt</text>
<preis>5,00</preis>
<status>Frei</status>
<richtung>HIN</richtung>
</leistung>
</lei_befoerderung>
<zustiege>
<zustieg id="1" idbuspro="873" zeit="27.03.2026 21:30:00" />
</zustiege>
</termin>
</reise>
</reisen>';
$crawler = new Crawler($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode);
$this->assertSame(12162, $travel->id);
$this->assertSame('PGTSGI280326', $travel->code);
$this->assertNull($travel->hotelId);
$this->assertSame([], $travel->rooms);
$this->assertArrayHasKey(188858, $travel->additionalServices);
$this->assertArrayHasKey(188850, $travel->transportationServices);
$this->assertArrayHasKey(873, $travel->pickups);
}
public function testParseAdditionalServicesUsesTerminLevelOnly(): void
{
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>