seed(RolePermissionSeeder::class); $this->superAdmin = User::factory()->create(); $this->superAdmin->assignRole('super_admin'); }); test('a super_admin can list and edit roles', function () { $this->actingAs($this->superAdmin)->get('/admin/roles')->assertSuccessful(); $role = Role::where('name', 'support')->firstOrFail(); $this->actingAs($this->superAdmin)->get("/admin/roles/{$role->id}/edit")->assertSuccessful(); }); test('an admin without manage_roles is forbidden from the role resource', function () { $admin = User::factory()->create(); $admin->assignRole('admin'); $this->actingAs($admin)->get('/admin/roles')->assertForbidden(); }); test('roles cannot be created or deleted from the resource', function () { expect(RoleResource::canCreate())->toBeFalse(); $role = Role::where('name', 'support')->firstOrFail(); expect(RoleResource::canDelete($role))->toBeFalse(); });