This commit is contained in:
2026-05-14 16:54:32 +00:00
parent 5b2a2e7ddb
commit 15fcbcc9eb
212 changed files with 18586 additions and 10360 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Models\Role;
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('/admin');
$response->assertRedirect('/login');
}
public function test_non_admin_user_cannot_access_admin_panel(): void
{
$role = Role::create(['libelle' => 'Utilisateur']);
$user = User::factory()->create(['id_role' => $role->id]);
$response = $this->actingAs($user)->get('/admin');
$response->assertForbidden();
}
public function test_admin_user_can_access_admin_panel(): void
{
$role = Role::create(['libelle' => 'Admin']);
$user = User::factory()->create(['id_role' => $role->id]);
$response = $this->actingAs($user)->get('/admin');
$response->assertSuccessful();
}
}