feat: make boarding point price levelling switchable
This commit is contained in:
1 parent
0c6126010f
commit
f5e6d2105d
8 files changed
+92
-13
No files matched your search
@@ -6,6 +6,7 @@ namespace App\Tests\BusProNet\XmlParser;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\XmlCrawlerFactory;
|
||||
use App\BusProNet\XmlParser\AgeConstraintParserRegistry;
|
||||
use App\BusProNet\XmlParser\TravelParser;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -16,7 +17,7 @@ class TravelParserTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->parser = new TravelParser();
|
||||
$this->parser = $this->createParser();
|
||||
}
|
||||
|
||||
public function testParseServiceDescriptions(): void
|
||||
@@ -411,7 +412,27 @@ class TravelParserTest extends TestCase
|
||||
$this->assertSame(5.9, $travel->dropOffs[99]->price);
|
||||
}
|
||||
|
||||
private function parseTravelWithBoardingPoints(string $pickups, string $dropOffs): Travel
|
||||
public function testBoardingPricesAreReportedVerbatimWhenLevellingIsDisabled(): void
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
private function createParser(bool $levelBoardingPointPrices = true): TravelParser
|
||||
{
|
||||
return new TravelParser(new AgeConstraintParserRegistry(), $levelBoardingPointPrices);
|
||||
}
|
||||
|
||||
private function parseTravelWithBoardingPoints(string $pickups, string $dropOffs, ?TravelParser $parser = null): Travel
|
||||
{
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
||||
<reisen>
|
||||
@@ -426,7 +447,7 @@ class TravelParserTest extends TestCase
|
||||
|
||||
$crawler = XmlCrawlerFactory::create($xmlContent);
|
||||
|
||||
return $this->parser->parse($crawler->filterXPath('//reise/termin')->first());
|
||||
return ($parser ?? $this->parser)->parse($crawler->filterXPath('//reise/termin')->first());
|
||||
}
|
||||
|
||||
public function testGetPickupsAdjustsOvernightTimes(): void
|
||||
|
||||
Reference in new issue
Block a user