wip: booking process, refactoring
This commit is contained in:
@@ -4,22 +4,45 @@ 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 testParse(): void
|
||||
public function testLoadAll(): void
|
||||
{
|
||||
$loader = new HotelLoader(__DIR__.'/../../Resources');
|
||||
$hotelId = 163113;
|
||||
$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>';
|
||||
|
||||
$xml = $loader->loadById($hotelId, 'hotels_data.xml');
|
||||
$this->assertInstanceOf(\SimpleXMLElement::class, $xml);
|
||||
$filesystem = $this->createMock(FilesystemOperator::class);
|
||||
$filesystem->expects($this->once())
|
||||
->method('read')
|
||||
->with('hotel.xml')
|
||||
->willReturn($xmlContent);
|
||||
|
||||
$hotel = $loader->parseXml($xml);
|
||||
$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($hotelId, $hotel->id);
|
||||
$this->assertEquals(163113, $hotel->id);
|
||||
$this->assertEquals('L\'Oxalys', $hotel->name);
|
||||
$this->assertEquals('SBWOXA', $hotel->code);
|
||||
$this->assertEquals('Val Thorens', $hotel->city);
|
||||
|
||||
Reference in New Issue
Block a user