<?php

namespace Tests\Feature;

use App\Models\Role;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AccessControlTest extends TestCase
{
    use RefreshDatabase;

    public function test_waiter_cannot_access_master_stands(): void
    {
        $role = Role::create(['nama_roles' => 'waiter', 'guard' => 'web']);
        $user = User::factory()->create(['roles_id' => $role->id]);

        $response = $this->actingAs($user)->get('/master/stands');

        $response->assertStatus(403);
    }

    public function test_guest_redirected_to_login(): void
    {
        $response = $this->get('/master/stands');

        $response->assertRedirect(route('login'));
    }
}
