This commit is contained in:
Laucha1312
2026-06-04 15:22:45 -03:00
parent cc70b74e5a
commit aa9bc585fd
12 changed files with 782 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use App\Models\AdminUser;
use App\Models\Club;
use App\Models\Jugador;
use App\Models\Pase;
use Illuminate\Support\Facades\Hash;
class PaseTest extends TestCase
{
use DatabaseTransactions;
public function test_superadmin_can_approve_a_transfer()
{
// 1. Setup: Dos clubes y un jugador en el club A
$clubA = Club::create(['id_club' => 101, 'nombre' => 'Club A']);
$clubB = Club::create(['id_club' => 102, 'nombre' => 'Club B']);
$jugador = Jugador::create([
'id_jugador' => 'T-PASE-1',
'documento' => '99000111',
'nombre' => 'Pedro',
'apellido' => 'Pase',
'id_club_actual' => $clubA->id_club,
'id_club_origen' => $clubA->id_club,
'activo' => true
]);
// 2. Crear solicitud de pase
$pase = Pase::create([
'id_jugador' => $jugador->id_jugador,
'id_club_origen' => $clubA->id_club,
'id_club_destino' => $clubB->id_club,
'estado' => 'Pendiente'
]);
// 3. Loguear como SuperAdmin
$this->withSession([
'admin_role' => 1,
'admin_logged_in' => true
]);
// 4. Ejecutar la aprobación
$response = $this->put(route('admin.pases.aprobar', $pase->id_pase));
// 5. Verificar redirección y base de datos
$response->assertRedirect(route('admin.pases.index'));
// El pase debe estar aprobado
$this->assertDatabaseHas('pases', [
'id_jugador' => $jugador->id_jugador,
'estado' => 'Aprobado'
]);
// El jugador debe haber cambiado de club actual
$jugador->refresh();
$this->assertEquals($clubB->id_club, $jugador->id_club_actual);
$this->assertEquals($clubA->id_club, $jugador->id_club_origen);
}
}