<?php

use App\Services\RbacService;
use PHPUnit\Framework\TestCase;

final class RbacServiceTest extends TestCase
{
    private RbacService $rbac;

    protected function setUp(): void
    {
        $this->rbac = new RbacService();
    }

    public function testSuperAdminHasAllAccess(): void
    {
        $this->assertTrue($this->rbac->can('super_admin', 'finance.ledger'));
        $this->assertTrue($this->rbac->canAccessRoute('super_admin', 'settings/users'));
    }

    public function testTechnicianCannotAccessFinanceLedger(): void
    {
        $this->assertFalse($this->rbac->canAccessRoute('technician', 'finance/ledger'));
        $this->assertTrue($this->rbac->canAccessRoute('technician', 'finance/reimbursements/create'));
    }

    public function testFinanceManagerPayments(): void
    {
        $this->assertTrue($this->rbac->canAccessRoute('finance_manager', 'finance/payments'));
    }
}
