54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\BusProNet\DataLoader;
|
|
|
|
use App\BusProNet\Model\Hotel;
|
|
use App\BusProNet\XmlLoader\HotelLoader;
|
|
use League\Flysystem\FilesystemOperator;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
|
|
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 ArrayAdapter();
|
|
$loader = new HotelLoader($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);
|
|
}
|
|
}
|