summaryrefslogtreecommitdiff
path: root/tests/Unit/Models/Shifts/ScheduleShiftTest.php
blob: b615f90dcac97d69964a4b7c8a718cdf1379435a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace Engelsystem\Test\Unit\Models\Shifts;

use Engelsystem\Models\Shifts\Schedule;
use Engelsystem\Models\Shifts\ScheduleShift;
use Engelsystem\Test\Unit\HasDatabase;
use Engelsystem\Test\Unit\TestCase;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ScheduleShiftTest extends TestCase
{
    use HasDatabase;

    /**
     * @covers \Engelsystem\Models\Shifts\ScheduleShift::schedule
     */
    public function testScheduleShifts()
    {
        $schedule = new Schedule(['url' => 'https://lorem.ipsum/schedule.xml']);
        $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);
    }

    /**
     * Prepare test
     */
    protected function setUp(): void
    {
        parent::setUp();
        $this->initDatabase();
    }
}