lastInsertId(),$actor);}; // Old fixture linked by the real seasonal licence, preserving the internal id and sanctions. $id=Sports::save('players',Sports::player(['licence_number'=>'89427490','last_name'=>'AMIL','first_name'=>'Riyad']),0,$actor); $san=Sports::save('sanctions',Sports::sanction(['player_id'=>$id,'effective_date'=>'2026-05-25','matches_required'=>2,'label'=>'Historique conservé']),0,$actor); foreach([$argv[1],$argv[2]] as $file){$rows=Csv::previewRows('players',0,Xlsx::read($file)['rows'],false,'2026/2027');$apply($rows);} ok((int)DB::value('SELECT COUNT(*) FROM players WHERE person_number IS NOT NULL')===100,'100 personnes pour les deux exports'); ok((int)DB::value("SELECT id FROM players WHERE person_number='2547084057'")===$id,'Ancienne fiche rapprochée par identifiant exact'); ok((int)DB::value('SELECT player_id FROM sanctions WHERE id=?',[$san])===$id,'Sanction existante conservée'); ok((int)DB::value("SELECT COUNT(*) FROM person_licences l JOIN players p ON p.id=l.player_id WHERE p.person_number='1152424516'")===2,'Deux licences pour une seule personne'); ok(DB::value("SELECT member_role FROM players WHERE person_number='1152424516'")==='player_staff','Double profil regroupé'); foreach([$argv[1],$argv[2]] as $file){$rows=Csv::previewRows('players',0,Xlsx::read($file)['rows'],false,'2026/2027');$c=$apply($rows);ok($c['create']===0&&$c['update']===0,'Réimport sans modification');} $row=Xlsx::read($argv[1])['rows'][0];$row['data']['numero_licence']='999999999';$apply(Csv::previewRows('players',0,[$row],false,'2027/2028')); ok((int)DB::value('SELECT COUNT(*) FROM players WHERE person_number IS NOT NULL')===100,'Nouvelle saison sans nouvelle personne'); $bad=Csv::previewRows('players',0,[$row]);ok($bad[0]['action']==='error','Saison obligatoire'); $disc=Csv::previewRows('discipline',0,Xlsx::read($argv[3])['rows']);ok(count(array_filter($disc,fn($r)=>$r['error']))===0,'Sanctions rapprochées par numéro personne');$apply($disc,'discipline'); People::migrate();ok((int)DB::value('SELECT COUNT(*) FROM players WHERE person_number IS NOT NULL')===100,'Migration relançable'); echo "$n tests personnes réussis\n";