<?php

namespace Tests\Unit\Services\Attendance;

use App\Services\Attendance\AttendancePolicyService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AttendancePolicyServiceTest extends TestCase
{
    use RefreshDatabase;

    public function test_teacher_can_edit_draft(): void
    {
        $service = new AttendancePolicyService();
        $allowed = $service->canEditDay(
            ['status' => 'draft'],
            ['roles' => ['Teacher'], 'permissions' => []]
        );

        $this->assertTrue($allowed);
    }

    public function test_teacher_cannot_edit_finalized(): void
    {
        $service = new AttendancePolicyService();
        $allowed = $service->canEditDay(
            ['status' => 'finalized'],
            ['roles' => ['Teacher'], 'permissions' => []]
        );

        $this->assertFalse($allowed);
    }

    public function test_admin_like_by_permission(): void
    {
        $service = new AttendancePolicyService();
        $isAdmin = $service->isAdminLike([], ['attendance.manage.daily']);

        $this->assertTrue($isAdmin);
    }
}
