39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Models;
|
|
|
|
use App\Models\Shift;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class ShiftTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_active_scope_returns_only_active_shifts(): void
|
|
{
|
|
$active = Shift::factory()->create();
|
|
Shift::factory()->inactive()->create();
|
|
|
|
$this->assertSame([$active->id], Shift::active()->pluck('id')->all());
|
|
}
|
|
|
|
public function test_open_scope_returns_only_unassigned_shifts(): void
|
|
{
|
|
$open = Shift::factory()->create();
|
|
Shift::factory()->forDoctor()->create();
|
|
|
|
$this->assertSame([$open->id], Shift::open()->pluck('id')->all());
|
|
}
|
|
|
|
public function test_scopes_can_be_chained(): void
|
|
{
|
|
$target = Shift::factory()->create();
|
|
Shift::factory()->inactive()->create();
|
|
Shift::factory()->forDoctor()->create();
|
|
Shift::factory()->forDoctor()->inactive()->create();
|
|
|
|
$this->assertSame([$target->id], Shift::active()->open()->pluck('id')->all());
|
|
}
|
|
}
|