Files
git-course/tests/Feature/RoleIndexTest.php
2026-05-11 11:41:27 +08:00

24 lines
556 B
PHP

<?php
use App\Models\Role;
use App\Models\User;
test('role index requires authentication', function () {
$this->get('/role')->assertRedirect('/login');
});
test('authenticated users can view the role index', function () {
Role::query()->create(['name' => 'Admin']);
Role::query()->create(['name' => 'Editor']);
$response = $this
->actingAs(User::factory()->create())
->get('/role');
$response
->assertSuccessful()
->assertSee('Roles')
->assertSee('Admin')
->assertSee('Editor');
});