Files
famous-ly4-ev/tests/Feature/AdminPanelAccessTest.php
T

20 lines
568 B
PHP
Raw Normal View History

<?php
use App\Models\User;
use Spatie\Permission\Models\Role;
test('a user with an admin-tier role can access the admin panel', function (string $role) {
Role::findOrCreate($role, 'web');
$user = User::factory()->create();
$user->assignRole($role);
$this->actingAs($user)->get('/admin')->assertSuccessful();
})->with(['super_admin', 'admin', 'support']);
test('a user without an admin-tier role cannot access the admin panel', function () {
$user = User::factory()->create();
$this->actingAs($user)->get('/admin')->assertForbidden();
});