Initial clean version

This commit is contained in:
root
2026-11-11 09:24:28 +01:00
commit ab58b33f9c
156 changed files with 5697 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
require dirname(__DIR__).'/bootstrap.php';
use App\{DB,Csv,Xlsx};
if(getenv('ESBSC_TEST_DATABASE')!=='1')exit('Base test requise');
function ok($v,$m){if(!$v)throw new RuntimeException($m);echo "OK $m\n";}
$actor=(int)DB::value('SELECT id FROM users LIMIT 1');
$raw=Xlsx::read($argv[1])['rows'];$rows=Csv::previewRows('discipline',0,$raw);
foreach($rows as $r)if($r['error'])throw new RuntimeException($r['error']);
ok(count(array_filter($rows,fn($r)=>($r['target']??'')==='yellow'))===8,'Huit cartons jaunes reconnus, staff inclus');
$apply=function($rows)use($actor){DB::query('INSERT INTO import_batches(actor_id,kind,filename,fingerprint,payload,base_revision) VALUES(?,?,?,?,?,?)',[$actor,'discipline','yellow.xlsx',hash('sha256',json_encode($rows)),json_encode($rows),DB::revision()]);Csv::apply((int)DB::conn()->lastInsertId(),$actor);};
$apply($rows);$before=DB::value("SELECT COUNT(*) FROM disciplinary_events WHERE source='footclubs_import'");
$again=Csv::previewRows('discipline',0,$raw);ok(count(array_filter($again,fn($r)=>($r['target']??'')==='yellow'&&$r['action']==='unchanged'))===8,'Réimport des huit jaunes identique');$apply($again);
ok(DB::value("SELECT COUNT(*) FROM disciplinary_events WHERE source='footclubs_import'")===$before,'Aucun doublon');
ok((int)DB::value("SELECT COUNT(*) FROM sanctions WHERE external_ref IN ('23990107','24010813','24006253','24010810','24010500','24010811','24022315','24022317')")===0,'Aucun jaune transformé en suspension');
ok(DB::value("SELECT warning_end_date FROM disciplinary_events WHERE source_ref='footclubs:23990107'")==='2026-11-29','Fin officielle du jaune ADAM conservée');
ok(DB::value("SELECT warning_effective_date FROM disciplinary_events WHERE source_ref='footclubs:24010813'")==='2026-09-06','Effet officiel du jaune BARBIER conservé');
DB::query("UPDATE disciplinary_events SET review_status='cancelled',review_reason='Correction justifiée pour test' WHERE source_ref='footclubs:23990107'");
$cancelled=Csv::previewRows('discipline',0,$raw);ok(count(array_filter($cancelled,fn($r)=>str_contains($r['error']??'','annulé manuellement')))===1,'Un réimport ne réactive pas un jaune annulé');