2019-11-27 23:43:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Models\Shifts;
|
|
|
|
|
|
|
|
use Engelsystem\Models\Shifts\Schedule;
|
|
|
|
use Engelsystem\Models\Shifts\ScheduleShift;
|
2022-11-08 00:33:42 +01:00
|
|
|
use Engelsystem\Models\Shifts\ShiftType;
|
2020-05-11 19:57:25 +02:00
|
|
|
use Engelsystem\Test\Unit\Models\ModelTest;
|
2019-11-27 23:43:21 +01:00
|
|
|
|
2020-05-11 19:57:25 +02:00
|
|
|
class ScheduleTest extends ModelTest
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
2022-11-08 00:33:42 +01:00
|
|
|
protected array $data = [
|
|
|
|
'url' => 'https://foo.bar/schedule.xml',
|
|
|
|
'name' => 'Testing',
|
|
|
|
'shift_type' => 1,
|
|
|
|
'minutes_before' => 10,
|
|
|
|
'minutes_after' => 10,
|
|
|
|
];
|
|
|
|
|
2019-11-27 23:43:21 +01:00
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Models\Shifts\Schedule::scheduleShifts
|
|
|
|
*/
|
2022-11-08 00:33:42 +01:00
|
|
|
public function testScheduleShifts(): void
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
2022-11-08 00:33:42 +01:00
|
|
|
$schedule = new Schedule($this->data);
|
2019-11-27 23:43:21 +01:00
|
|
|
$schedule->save();
|
|
|
|
|
|
|
|
(new ScheduleShift(['shift_id' => 1, 'schedule_id' => $schedule->id, 'guid' => 'a']))->save();
|
|
|
|
(new ScheduleShift(['shift_id' => 2, 'schedule_id' => $schedule->id, 'guid' => 'b']))->save();
|
|
|
|
(new ScheduleShift(['shift_id' => 3, 'schedule_id' => $schedule->id, 'guid' => 'c']))->save();
|
|
|
|
|
|
|
|
$this->assertCount(3, $schedule->scheduleShifts);
|
|
|
|
}
|
2022-11-08 00:33:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Models\Shifts\Schedule::shiftType
|
|
|
|
*/
|
|
|
|
public function testShiftType(): void
|
|
|
|
{
|
|
|
|
$st = new ShiftType(['name' => 'Shift Type', 'description' => '']);
|
|
|
|
$st->save();
|
|
|
|
|
|
|
|
$schedule = new Schedule($this->data);
|
|
|
|
$schedule->save();
|
|
|
|
$schedule->shiftType()->associate($st);
|
|
|
|
|
|
|
|
$this->assertEquals('Shift Type', Schedule::find(1)->shiftType->name);
|
|
|
|
}
|
2019-11-27 23:43:21 +01:00
|
|
|
}
|