seed(RolesAndPermissionsSeeder::class); }); test('access-admin gate mirrors canAccessAdmin', function () { $admin = User::factory()->create(['is_active' => true]); $admin->assignRole('admin'); $customer = User::factory()->create(['is_active' => true]); $customer->assignRole('customer'); expect(Gate::forUser($admin)->allows('access-admin'))->toBeTrue() ->and(Gate::forUser($customer)->allows('access-admin'))->toBeFalse(); }); test('access-customer gate mirrors canAccessCustomer', function () { $customer = User::factory()->create(['is_active' => true]); $customer->assignRole('customer'); $apiOnly = User::factory()->create(['is_active' => true]); $apiOnly->assignRole('api-only'); expect(Gate::forUser($customer)->allows('access-customer'))->toBeTrue() ->and(Gate::forUser($apiOnly)->allows('access-customer'))->toBeFalse(); }); test('a non-admin user is forbidden from the admin dashboard', function () { $customer = User::factory()->create(['is_active' => true]); $customer->assignRole('customer'); $this->actingAs($customer) ->get(route('dashboard')) ->assertForbidden(); });