2019-11-27 23:43:21 +01:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-11-27 23:43:21 +01:00
|
|
|
namespace Engelsystem\Test\Unit\Helpers\Schedule;
|
|
|
|
|
|
|
|
use Engelsystem\Helpers\Schedule\Day;
|
|
|
|
use Engelsystem\Helpers\Schedule\Event;
|
|
|
|
use Engelsystem\Helpers\Schedule\Room;
|
|
|
|
use Engelsystem\Helpers\Schedule\XmlParser;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
|
|
|
class XmlParserTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\XmlParser::load
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\XmlParser::parseXml
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\XmlParser::parseEvents
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\XmlParser::getFirstXpathContent
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\XmlParser::getListFromSequence
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\XmlParser::getSchedule
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testLoad(): void
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
|
|
|
$parser = new XmlParser();
|
2020-04-06 21:11:19 +02:00
|
|
|
|
|
|
|
// Invalid XML
|
2019-11-27 23:43:21 +01:00
|
|
|
$this->assertFalse($parser->load('foo'));
|
2023-09-17 13:25:11 +02:00
|
|
|
// Invalid schedule
|
|
|
|
$this->assertFalse($parser->load(file_get_contents(__DIR__ . '/Assets/schedule-invalid.html')));
|
|
|
|
|
2020-04-06 21:11:19 +02:00
|
|
|
// Minimal import
|
|
|
|
$this->assertTrue($parser->load(file_get_contents(__DIR__ . '/Assets/schedule-minimal.xml')));
|
|
|
|
// Basic import
|
|
|
|
$this->assertTrue($parser->load(file_get_contents(__DIR__ . '/Assets/schedule-basic.xml')));
|
|
|
|
// Extended import
|
|
|
|
$this->assertTrue($parser->load(file_get_contents(__DIR__ . '/Assets/schedule-extended.xml')));
|
2019-11-27 23:43:21 +01:00
|
|
|
|
|
|
|
$schedule = $parser->getSchedule();
|
|
|
|
$this->assertEquals('Some version string', $schedule->getVersion());
|
|
|
|
$this->assertEquals('Test Event', $schedule->getConference()->getTitle());
|
|
|
|
|
|
|
|
/** @var Room $room */
|
|
|
|
$room = Arr::first($schedule->getRooms());
|
|
|
|
$this->assertEquals('Rooming', $room->getName());
|
|
|
|
|
|
|
|
/** @var Day $day */
|
2021-12-28 14:43:23 +01:00
|
|
|
$day = Arr::first($schedule->getDays());
|
2019-11-27 23:43:21 +01:00
|
|
|
$this->assertEquals('2042-01-01', $day->getDate());
|
|
|
|
$this->assertEquals(1, $day->getIndex());
|
|
|
|
|
|
|
|
/** @var Room $room */
|
2021-12-28 14:43:23 +01:00
|
|
|
$room = Arr::first($day->getRooms());
|
2019-11-27 23:43:21 +01:00
|
|
|
/** @var Event $event */
|
2021-12-28 14:43:23 +01:00
|
|
|
$event = Arr::first($room->getEvents());
|
2019-11-27 23:43:21 +01:00
|
|
|
|
|
|
|
$this->assertEquals('Foo Bar Test', $event->getTitle());
|
|
|
|
$this->assertEquals('WTFPL', $event->getRecording());
|
|
|
|
$this->assertEquals('de', $event->getLanguage());
|
|
|
|
$this->assertEquals('12:30', $event->getStart());
|
|
|
|
$this->assertEquals([1234 => 'Some Person'], $event->getPersons());
|
2020-04-06 21:11:19 +02:00
|
|
|
$this->assertEquals('https://foo.bar/baz/schedule/ipsum/recording.mp4', $event->getVideoDownloadUrl());
|
2019-11-27 23:43:21 +01:00
|
|
|
}
|
|
|
|
}
|