Runs is_admin migration, adds AdminSeeder for the admin user, registers it in DatabaseSeeder, adds admin() factory state to UserFactory, and adds AdminAccessTest covering both forbidden and ok cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
21 lines
474 B
PHP
21 lines
474 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('denies non-admin users access to admin panel', function () {
|
|
$user = User::factory()->create();
|
|
$this->actingAs($user);
|
|
|
|
$this->get('/admin')->assertForbidden();
|
|
});
|
|
|
|
it('allows admin users to access admin panel', function () {
|
|
$user = User::factory()->admin()->create();
|
|
$this->actingAs($user);
|
|
|
|
$this->get('/admin')->assertOk();
|
|
});
|