<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use Tests\Traits\WithTestAuth;

class AdminOperationsTest extends TestCase
{
    use RefreshDatabase;
    use WithTestAuth;

    private $admin;

    protected function setUp(): void
    {
        parent::setUp();
        // Granular permissions for operations
        $permissions = [
            'ViewAny:User',
            'ViewAny:QuestionSet',
            'ViewAny:Exam',
            'Delete:User',
            'Delete:QuestionSet',
            'Delete:Exam',
            'ViewAny:Role',
        ];

        $this->admin = $this->createAdminUser($permissions);
    }

    public function test_admin_can_access_users_management(): void
    {
        $this->actingAs($this->admin)
            ->get('/admin/users')
            ->assertStatus(200);
    }

    public function test_admin_can_access_question_sets(): void
    {
        $this->actingAs($this->admin)
            ->get('/admin/question-sets')
            ->assertStatus(200);
    }

    public function test_admin_can_access_exams_management(): void
    {
        $this->actingAs($this->admin)
            ->get('/admin/exams')
            ->assertStatus(200);
    }
}
