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;
|
2023-01-03 22:19:03 +01:00
|
|
|
use Engelsystem\Models\Shifts\Shift;
|
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
|
2023-01-03 22:19:03 +01:00
|
|
|
* @covers \Engelsystem\Models\Shifts\ScheduleShift::shift
|
2019-11-27 23:43:21 +01:00
|
|
|
*/
|
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();
|
2023-01-03 22:19:03 +01:00
|
|
|
/** @var Shift $shift */
|
|
|
|
$shift = Shift::factory()->create();
|
2019-11-27 23:43:21 +01:00
|
|
|
|
2023-01-03 22:19:03 +01:00
|
|
|
$scheduleShift = new ScheduleShift(['guid' => 'a']);
|
2019-11-27 23:43:21 +01:00
|
|
|
$scheduleShift->schedule()->associate($schedule);
|
2023-01-03 22:19:03 +01:00
|
|
|
$scheduleShift->shift()->associate($shift);
|
2019-11-27 23:43:21 +01:00
|
|
|
$scheduleShift->save();
|
|
|
|
|
|
|
|
/** @var ScheduleShift $scheduleShift */
|
|
|
|
$scheduleShift = (new ScheduleShift())->find(1);
|
|
|
|
$this->assertInstanceOf(BelongsTo::class, $scheduleShift->schedule());
|
|
|
|
$this->assertEquals($schedule->id, $scheduleShift->schedule->id);
|
2023-01-03 22:19:03 +01:00
|
|
|
$this->assertInstanceOf(BelongsTo::class, $scheduleShift->shift());
|
|
|
|
$this->assertEquals($shift->id, $scheduleShift->shift->id);
|
2019-11-27 23:43:21 +01:00
|
|
|
}
|
|
|
|
}
|