The Teamer app groups hotels by cost unit and renders a flag per destination, and cannot derive either from what /api/hotels returns today. costUnit is the raw kostenstelle and stays a string: only 281 of 1931 hotels carry one and some hold a space-separated list such as "84 85". countryCode goes through CountryCodeMapper, whose table is part of the API contract: BusPro's land column mixes ISO-2, ISO-3 and European vehicle registration codes for the same country, and a wrong entry mislabels a destination's flag silently. An unmappable token is null and warns on the bpn channel, never a guess. country itself is untouched -- it remains the join key into /api/countries[].token. Co-Authored-By: Claude Opus 5 <[email protected]>
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\BusProNet\DataLoader;
|
|
|
|
use App\BusProNet\Model\Hotel;
|
|
use App\BusProNet\Utility\CountryCodeMapper;
|
|
use App\BusProNet\XmlLoader\HotelLoader;
|
|
use League\Flysystem\FilesystemOperator;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psr\Log\NullLogger;
|
|
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
|
|
|
|
class HotelDataLoaderTest extends TestCase
|
|
{
|
|
public function testLoadAll(): void
|
|
{
|
|
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>
|
|
<!--Export für dreipunktnull büro für mediengestaltung-->
|
|
<hotels erstellt_am="14.07.2025 15:04:46">
|
|
<hotel id="1" idbuspro="163113" code="SBWOXA">
|
|
<name>L\'Oxalys</name>
|
|
<ort>Val Thorens</ort>
|
|
<land>F</land>
|
|
<strasse>Rue des Lacs</strasse>
|
|
<telefon></telefon>
|
|
<art>Hotel</art>
|
|
<internetbuchbar>True</internetbuchbar>
|
|
</hotel>
|
|
</hotels>';
|
|
|
|
$filesystem = $this->createMock(FilesystemOperator::class);
|
|
$filesystem->expects($this->once())
|
|
->method('read')
|
|
->with('hotel.xml')
|
|
->willReturn($xmlContent);
|
|
|
|
$cache = new TagAwareAdapter(new ArrayAdapter());
|
|
$loader = new HotelLoader(new CountryCodeMapper(new NullLogger()), $cache, $filesystem);
|
|
|
|
$hotels = $loader->loadAll();
|
|
|
|
$this->assertIsArray($hotels);
|
|
$this->assertArrayHasKey(163113, $hotels);
|
|
|
|
$hotel = $hotels[163113];
|
|
$this->assertInstanceOf(Hotel::class, $hotel);
|
|
$this->assertEquals(163113, $hotel->id);
|
|
$this->assertEquals('L\'Oxalys', $hotel->name);
|
|
$this->assertEquals('SBWOXA', $hotel->code);
|
|
$this->assertEquals('Val Thorens', $hotel->city);
|
|
$this->assertEquals('F', $hotel->country);
|
|
$this->assertEquals('Rue des Lacs', $hotel->street);
|
|
$this->assertEquals('', $hotel->phone);
|
|
$this->assertEquals('fr', $hotel->countryCode);
|
|
$this->assertNull($hotel->costUnit);
|
|
}
|
|
}
|