chore: remove boarding point price levelling

This commit is contained in:
fromme committed 2026-10-19 10:29:12 +02:00
1 parent 3f941bb4bf
commit 57b86a8fbc
10 files changed
+23 -144

No files matched your search

+13 -54
View File
@@ -357,49 +357,23 @@ class TravelParserTest extends TestCase
$this->assertNull($travel->status); // No status_hin node should result in null
}
public function testDropOffsInheritThePickupPriceWhenTheReturnLegStatesNone(): void
public function testBoardingPricesAreReportedVerbatimPerLeg(): void
{
// Shape of product 701: the return boarding points carry no preis although
// BusPro bills an Abfahrtsortzuschlag for the return leg as well.
// BusPro bills the return-leg Abfahrtsortzuschlag only where the return entry
// states a preis, so an unpriced return leg is free and each leg keeps its own price.
$travel = $this->parseTravelWithBoardingPoints(
'<zustieg idbuspro="18" zeit="12.12.2026 21:45:00" preis="17,90" />
<zustieg idbuspro="27" zeit="03:45" />',
<zustieg idbuspro="4" zeit="12.12.2026 22:30:00" preis="17,90" />',
'<zustieg_rueck idbuspro="18" />
<zustieg_rueck idbuspro="27" />'
);
$this->assertSame(17.9, $travel->dropOffs[18]->price);
$this->assertSame(17.9, $travel->dropOffs[18]->priceInbound);
$this->assertSame(17.9, $travel->pickups[18]->priceInbound);
// A point that is free outbound stays free on the return leg
$this->assertNull($travel->dropOffs[27]->price);
$this->assertNull($travel->pickups[27]->priceInbound);
}
public function testPickupInheritsTheDropOffPriceWhenTheOutboundLegStatesNone(): void
{
// The mirror image of the product 701 defect: an asymmetric pair is a defect
// whichever leg is missing, so the stated price applies to both.
$travel = $this->parseTravelWithBoardingPoints(
'<zustieg idbuspro="18" zeit="12.12.2026 21:45:00" />',
'<zustieg_rueck idbuspro="18" preis="17,90" />'
<zustieg_rueck idbuspro="4" preis="9,90" />'
);
$this->assertSame(17.9, $travel->pickups[18]->price);
$this->assertSame(17.9, $travel->pickups[18]->priceOutbound);
$this->assertSame(17.9, $travel->dropOffs[18]->price);
}
$this->assertNull($travel->pickups[18]->priceInbound);
$this->assertNull($travel->dropOffs[18]->price);
public function testConflictingBoardingPricesResolveToTheOutboundOne(): void
{
$travel = $this->parseTravelWithBoardingPoints(
'<zustieg idbuspro="18" zeit="12.12.2026 21:45:00" preis="17,90" />',
'<zustieg_rueck idbuspro="18" preis="9,90" />'
);
$this->assertSame(17.9, $travel->pickups[18]->price);
$this->assertSame(17.9, $travel->dropOffs[18]->price);
$this->assertSame(17.9, $travel->pickups[4]->price);
$this->assertSame(9.9, $travel->dropOffs[4]->price);
}
public function testDropOffWithoutAPickupCounterpartKeepsItsOwnPrice(): void
@@ -412,27 +386,12 @@ class TravelParserTest extends TestCase
$this->assertSame(5.9, $travel->dropOffs[99]->price);
}
public function testBoardingPricesAreReportedVerbatimWhenLevellingIsDisabled(): void
private function createParser(): TravelParser
{
// The levelling compensates a vendor export defect and is therefore switchable.
// With it off the product 701 shape undercharges the return leg again.
$travel = $this->parseTravelWithBoardingPoints(
'<zustieg idbuspro="18" zeit="12.12.2026 21:45:00" preis="17,90" />',
'<zustieg_rueck idbuspro="18" />',
$this->createParser(levelBoardingPointPrices: false)
);
$this->assertSame(17.9, $travel->pickups[18]->price);
$this->assertNull($travel->pickups[18]->priceInbound);
$this->assertNull($travel->dropOffs[18]->price);
return new TravelParser(new AgeConstraintParserRegistry());
}
private function createParser(bool $levelBoardingPointPrices = true): TravelParser
{
return new TravelParser(new AgeConstraintParserRegistry(), $levelBoardingPointPrices);
}
private function parseTravelWithBoardingPoints(string $pickups, string $dropOffs, ?TravelParser $parser = null): Travel
private function parseTravelWithBoardingPoints(string $pickups, string $dropOffs): Travel
{
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
<reisen>
@@ -447,7 +406,7 @@ class TravelParserTest extends TestCase
$crawler = XmlCrawlerFactory::create($xmlContent);
return ($parser ?? $this->parser)->parse($crawler->filterXPath('//reise/termin')->first());
return $this->parser->parse($crawler->filterXPath('//reise/termin')->first());
}
public function testGetPickupsAdjustsOvernightTimes(): void