Files
fitness/tests/Feature/Admin/AdminAccessTest.php
T
rootandClaude Sonnet 5 0a36afbfdc Add feature test coverage for the core domain
Only Breeze's default auth/profile tests existed - nothing covered
Workouts, Sessions, Exercises, Yoga, Favorites, Blog, or the Admin
panel, which is the actual product. Adds factories for the domain
models and 45 new feature tests covering the main flows plus
authorization boundaries (owner-only access on workouts/sessions,
admin-only access on /admin, drafts hidden from the public blog).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 11:47:51 +03:00

40 lines
896 B
PHP

<?php
namespace Tests\Feature\Admin;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminAccessTest extends TestCase
{
use RefreshDatabase;
public function test_guest_is_redirected_to_login(): void
{
$response = $this->get(route('admin.dashboard'));
$response->assertRedirect(route('login'));
}
public function test_regular_user_is_forbidden(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->get(route('admin.dashboard'));
$response->assertForbidden();
}
public function test_admin_can_view_dashboard(): void
{
$admin = User::factory()->create();
$admin->is_admin = true;
$admin->save();
$response = $this->actingAs($admin)->get(route('admin.dashboard'));
$response->assertOk();
}
}