24 lines
811 B
PHP
24 lines
811 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
|
|
$adminRoutes = ['admin.overview', 'admin.customers', 'admin.instances', 'admin.hosts', 'admin.provisioning', 'admin.revenue'];
|
|
|
|
it('redirects guests from the admin console to login', function (string $route) {
|
|
$this->get(route($route))->assertRedirect('/login');
|
|
})->with($adminRoutes);
|
|
|
|
it('forbids non-admin users from the admin console', function (string $route) {
|
|
$user = User::factory()->create(['is_admin' => false]);
|
|
|
|
$this->actingAs($user)->get(route($route))->assertForbidden();
|
|
})->with($adminRoutes);
|
|
|
|
it('renders the admin console for admins', function (string $route) {
|
|
$admin = User::factory()->create(['is_admin' => true]);
|
|
|
|
$this->actingAs($admin)->get(route($route))
|
|
->assertOk()
|
|
->assertSee('CluPilot');
|
|
})->with($adminRoutes);
|