parser = new ExtendedAvailabilitiesParser(); } public function testParsesServicesWithAllAttributes(): void { $xml = ' '; $crawler = XmlCrawlerFactory::create($xml); $response = $this->parser->parseServices($crawler); $services = $response->getServices(); $this->assertArrayHasKey(101, $services); $availability = $services[101]; $this->assertSame(101, $availability->serviceId); $this->assertSame('Frei', $availability->status); $this->assertSame(8, $availability->available); $this->assertSame(29.90, $availability->price); $this->assertSame('2030-01-01', $availability->dateFrom->format('Y-m-d')); $this->assertSame('2030-01-06', $availability->dateTo->format('Y-m-d')); $this->assertSame('09:00', $availability->timeFrom); $this->assertSame('Bitte anmelden', $availability->description); $this->assertSame(10, $availability->ageFrom); $this->assertSame(65, $availability->ageTo); $this->assertTrue($availability->mandatory); } public function testIgnoresEmptyAgeAndMandatoryAttributes(): void { $xml = ' '; $crawler = XmlCrawlerFactory::create($xml); $response = $this->parser->parseServices($crawler); $services = $response->getServices(); $this->assertArrayHasKey(102, $services); $availability = $services[102]; $this->assertNull($availability->ageFrom); $this->assertNull($availability->ageTo); $this->assertNull($availability->mandatory); } public function testParsesTravelLevelMetadata(): void { $xml = ' '; $crawler = XmlCrawlerFactory::create($xml); $response = $this->parser->parseServices($crawler); $this->assertSame('Frei', $response->travelStatus); $this->assertSame(['F', 'A'], $response->allowedBookingStatus); } public function testEmptyBuchungstatusmoeglichProducesNoStatusCodes(): void { $xml = ' '; $crawler = XmlCrawlerFactory::create($xml); $response = $this->parser->parseServices($crawler); $this->assertSame([], $response->allowedBookingStatus); } public function testMissingReiseNodeLeavesMetadataNullAndEmpty(): void { $xml = ' '; $crawler = XmlCrawlerFactory::create($xml); $response = $this->parser->parseServices($crawler); $this->assertNull($response->travelStatus); $this->assertSame([], $response->allowedBookingStatus); } public function testEmptyServicesCollection(): void { $xml = ' '; $crawler = XmlCrawlerFactory::create($xml); $response = $this->parser->parseServices($crawler); $this->assertSame([], $response->getServices()); } }