<?php

namespace Tests\Unit;

use App\Models\User;
use Filament\Panel;
use Mockery;
use Tests\TestCase;

class UserFilamentAccessTest extends TestCase
{
    public function test_admin_user_can_access_the_admin_panel(): void
    {
        $panel = Mockery::mock(Panel::class);
        $panel->shouldReceive('getId')->once()->andReturn('admin');

        $user = new User([
            'first_name' => 'Admin',
            'last_name' => 'User',
            'email' => 'admin@example.com',
            'phone' => '8112345678',
            'is_admin' => true,
            'password' => 'password123',
        ]);

        $this->assertTrue($user->canAccessPanel($panel));
    }

    public function test_non_admin_user_cannot_access_the_admin_panel(): void
    {
        $panel = Mockery::mock(Panel::class);
        $panel->shouldReceive('getId')->once()->andReturn('admin');

        $user = new User([
            'first_name' => 'Regular',
            'last_name' => 'User',
            'email' => 'user@example.com',
            'phone' => '8112345678',
            'is_admin' => false,
            'password' => 'password123',
        ]);

        $this->assertFalse($user->canAccessPanel($panel));
    }
}
