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;
|
2020-05-11 19:57:25 +02:00
|
|
|
use Engelsystem\Test\Unit\Models\ModelTest;
|
2019-11-27 23:43:21 +01:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
2020-05-11 19:57:25 +02:00
|
|
|
class ScheduleShiftTest extends ModelTest
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Models\Shifts\ScheduleShift::schedule
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testScheduleShifts(): void
|
2019-11-27 23:43:21 +01:00
|
|
|
{
|
2020-11-21 20:54:04 +01:00
|
|
|
$schedule = new Schedule([
|
|
|
|
'url' => 'https://lorem.ipsum/schedule.xml',
|
|
|
|
'name' => 'Test',
|
|
|
|
'shift_type' => 0,
|
|
|
|
'minutes_before' => 15,
|
|
|
|
'minutes_after' => 15,
|
|
|
|
]);
|
2019-11-27 23:43:21 +01:00
|
|
|
$schedule->save();
|
|
|
|
|
|
|
|
$scheduleShift = new ScheduleShift(['shift_id' => 1, 'guid' => 'a']);
|
|
|
|
$scheduleShift->schedule()->associate($schedule);
|
|
|
|
$scheduleShift->save();
|
|
|
|
|
|
|
|
/** @var ScheduleShift $scheduleShift */
|
|
|
|
$scheduleShift = (new ScheduleShift())->find(1);
|
|
|
|
$this->assertInstanceOf(BelongsTo::class, $scheduleShift->schedule());
|
|
|
|
$this->assertEquals($schedule->id, $scheduleShift->schedule->id);
|
|
|
|
}
|
|
|
|
}
|