get('/admin'); $response->assertStatus(403); } public function test_player_cannot_access_admin_dashboard() { // Simular que un jugador está logueado $this->withSession(['user_logged_in' => true, 'user_tipo' => 'jugador']); $response = $this->get('/admin'); // El middleware/controlador debería redirigirlo por no ser admin $response->assertStatus(403); } public function test_superadmin_can_access_admin_dashboard() { AdminUser::create([ 'username' => 'supertest', 'password' => Hash::make('123456'), 'role' => 1 ]); $this->withSession([ 'admin_logged_in' => true, 'admin_role' => 1, 'admin_username' => 'supertest' ]); $response = $this->get('/admin'); $response->assertStatus(200); $response->assertSee('Resumen General'); } public function test_superadmin_can_create_a_club() { Storage::fake('public'); $this->withSession([ 'admin_logged_in' => true, 'admin_role' => 1, 'admin_username' => 'supertest' ]); // Evitamos enviar una imagen real para no depender del File System $response = $this->post('/admin/clubes', [ 'id_club' => 999, 'nombre' => 'Club Atlético Test', 'localidad' => 'Testville', 'direccion' => 'Calle Falsa 123', 'activo' => 1 ]); $response->assertRedirect(route('admin.clubes.index')); $this->assertDatabaseHas('clubes', [ 'nombre' => 'Club Atlético Test' ]); } }