parser = new ContingentParser();
}
public function testParseBuildsRoomTypesAndRowsWithLinksAndControlRoom(): void
{
$xml = <<<'XML'
XML;
$result = $this->parser->parse($xml);
$this->assertArrayHasKey('roomTypes', $result);
$this->assertArrayHasKey('rows', $result);
$this->assertCount(3, $result['roomTypes']); // PDGS skipped
$this->assertCount(3, $result['rows']);
$rowsByCode = [];
foreach ($result['rows'] as $row) {
$rowsByCode[$row['roomCode']] = $row;
}
$this->assertSame('OK', $rowsByCode['DZ']['status']);
$this->assertSame(6, $rowsByCode['DZ']['pax']);
$this->assertSame(2, $rowsByCode['DZ']['available']);
$this->assertSame(100.0, $rowsByCode['DZ']['minPrice']);
$this->assertSame(2, $rowsByCode['DZ']['minNights']);
$this->assertSame(15.0, $rowsByCode['DZ']['additionalNightMinPrice']);
$this->assertSame(1, $rowsByCode['DZ']['additionalNightMinNights']);
$this->assertFalse($rowsByCode['DZ']['isControlRoom']);
// Linked room uses DZ contingent node but its own pax
$this->assertSame('Single Room', $rowsByCode['EZ']['roomLabel']);
$this->assertSame(3, $rowsByCode['EZ']['pax']);
$this->assertSame(1, $rowsByCode['EZ']['available']);
$this->assertSame('ON_REQUEST', $rowsByCode['BelKal']['status']);
$this->assertSame(0, $rowsByCode['BelKal']['pax']);
$this->assertSame(0, $rowsByCode['BelKal']['available']);
$this->assertTrue($rowsByCode['BelKal']['isControlRoom']);
}
public function testParseHandlesZeroValuesAndBlockedStatus(): void
{
$xml = <<<'XML'
XML;
$result = $this->parser->parse($xml);
$row = $result['rows'][0];
$this->assertSame('BLOCKED', $row['status']);
$this->assertSame(0, $row['pax']);
$this->assertSame(0, $row['available']);
$this->assertSame(0.0, $row['minPrice']);
$this->assertSame(0, $row['minNights']);
$this->assertSame(0.0, $row['additionalNightMinPrice']);
$this->assertSame(0, $row['additionalNightMinNights']);
}
}