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 Carbon\Carbon;
|
|
|
|
use Engelsystem\Helpers\Schedule\Conference;
|
|
|
|
use Engelsystem\Helpers\Schedule\Day;
|
|
|
|
use Engelsystem\Helpers\Schedule\Room;
|
|
|
|
use Engelsystem\Helpers\Schedule\Schedule;
|
2023-12-17 23:42:23 +01:00
|
|
|
use Engelsystem\Helpers\Schedule\ScheduleGenerator;
|
2019-11-27 23:43:21 +01:00
|
|
|
use Engelsystem\Test\Unit\HasDatabase;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
|
|
|
|
class ScheduleTest extends TestCase
|
|
|
|
{
|
|
|
|
use HasDatabase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::__construct
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getVersion
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getConference
|
2021-12-28 14:43:23 +01:00
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getDays
|
2023-12-17 23:42:23 +01:00
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getGenerator
|
2019-11-27 23:43:21 +01:00
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testCreate(): void
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
|
|
|
$conference = new Conference('Foo Bar', 'FooB');
|
|
|
|
$days = [$this->createMock(Day::class)];
|
|
|
|
$schedule = new Schedule('Foo\'ing stuff 1.0', $conference, $days);
|
|
|
|
|
|
|
|
$this->assertEquals('Foo\'ing stuff 1.0', $schedule->getVersion());
|
|
|
|
$this->assertEquals($conference, $schedule->getConference());
|
2021-12-28 14:43:23 +01:00
|
|
|
$this->assertEquals($days, $schedule->getDays());
|
2023-12-17 23:42:23 +01:00
|
|
|
$this->assertNull($schedule->getGenerator());
|
2019-11-27 23:43:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getRooms
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGetRooms(): void
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
|
|
|
$conference = new Conference('Test', 'T');
|
|
|
|
$room1 = new Room('Test 1');
|
|
|
|
$room2 = new Room('Test 2');
|
|
|
|
$room3 = new Room('Test 3');
|
|
|
|
$days = [
|
|
|
|
new Day(
|
|
|
|
'2042-01-01',
|
|
|
|
new Carbon('2042-01-01T00:00:00+00:00'),
|
|
|
|
new Carbon('2042-01-01T23:59:00+00:00'),
|
|
|
|
1,
|
|
|
|
[$room1, $room2]
|
|
|
|
),
|
|
|
|
new Day(
|
|
|
|
'2042-01-02',
|
|
|
|
new Carbon('2042-02-01T00:00:00+00:00'),
|
|
|
|
new Carbon('2042-02-01T23:59:00+00:00'),
|
|
|
|
2,
|
|
|
|
[new Room('Test 2'), $room3]
|
|
|
|
),
|
|
|
|
];
|
|
|
|
$schedule = new Schedule('Lorem 1.3.3.7', $conference, $days);
|
|
|
|
|
|
|
|
$this->assertEquals(['Test 1' => $room1, 'Test 2' => $room2, 'Test 3' => $room3], $schedule->getRooms());
|
|
|
|
|
|
|
|
$schedule = new Schedule('Lorem 1.3.3.0', $conference, []);
|
|
|
|
$this->assertEquals([], $schedule->getRooms());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getStartDateTime
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getEndDateTime
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testGetDateTimes(): void
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
|
|
|
$conference = new Conference('Some Conference', 'SC');
|
|
|
|
$days = [
|
|
|
|
new Day(
|
|
|
|
'2042-01-02',
|
|
|
|
new Carbon('2042-01-02T00:00:00+00:00'),
|
|
|
|
new Carbon('2042-01-02T23:59:00+00:00'),
|
|
|
|
2
|
|
|
|
),
|
|
|
|
new Day(
|
|
|
|
'2042-01-01',
|
|
|
|
new Carbon('2042-01-01T00:00:00+00:00'),
|
|
|
|
new Carbon('2042-01-01T23:59:00+00:00'),
|
|
|
|
1
|
|
|
|
),
|
|
|
|
new Day(
|
|
|
|
'2042-01-04',
|
|
|
|
new Carbon('2042-01-04T00:00:00+00:00'),
|
|
|
|
new Carbon('2042-01-04T23:59:00+00:00'),
|
|
|
|
3
|
|
|
|
),
|
|
|
|
];
|
|
|
|
$schedule = new Schedule('Ipsum tester', $conference, $days);
|
|
|
|
|
|
|
|
$this->assertEquals('2042-01-01T00:00:00+00:00', $schedule->getStartDateTime()->format(Carbon::RFC3339));
|
|
|
|
$this->assertEquals('2042-01-04T23:59:00+00:00', $schedule->getEndDateTime()->format(Carbon::RFC3339));
|
|
|
|
|
|
|
|
$schedule = new Schedule('Ipsum old', $conference, []);
|
|
|
|
$this->assertNull($schedule->getStartDateTime());
|
|
|
|
$this->assertNull($schedule->getEndDateTime());
|
|
|
|
}
|
|
|
|
|
2023-12-17 23:42:23 +01:00
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::__construct
|
|
|
|
* @covers \Engelsystem\Helpers\Schedule\Schedule::getGenerator
|
|
|
|
*/
|
|
|
|
public function testGetGenerator(): void
|
|
|
|
{
|
|
|
|
$conference = new Conference('Foo Bar', 'FooB');
|
|
|
|
$generator = new ScheduleGenerator('test', '1337');
|
|
|
|
$schedule = new Schedule('1.0', $conference, [], $generator);
|
|
|
|
|
|
|
|
$this->assertEquals($generator, $schedule->getGenerator());
|
|
|
|
}
|
|
|
|
|
2019-11-27 23:43:21 +01:00
|
|
|
/**
|
|
|
|
* Prepare test
|
|
|
|
*/
|
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->initDatabase();
|
|
|
|
}
|
|
|
|
}
|