Initial clean version
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require dirname(__DIR__).'/bootstrap.php';
|
||||
use App\{DB,Csv,CalendarAlerts,ClubSettings};
|
||||
if(getenv('ESBSC_TEST_DATABASE')!=='1')exit('Base jetable requise');
|
||||
function checkVenue(bool $ok,string $message):void{if(!$ok)throw new RuntimeException($message);echo "OK $message\n";}
|
||||
DB::query("INSERT INTO users(name,email,password_hash,role) VALUES('Test','terrain@example.test','disabled','admin')");$actor=(int)DB::conn()->lastInsertId();
|
||||
function importVenue(array $r,int $actor):array {
|
||||
$rows=Csv::previewRows('calendar',1,[['line'=>2,'data'=>$r]]);
|
||||
if($rows[0]['error'])throw new RuntimeException($rows[0]['error']);
|
||||
DB::query("INSERT INTO import_batches(actor_id,kind,team_id,filename,fingerprint,payload,base_revision) VALUES(?,'calendar',1,'fixture-terrain.xlsx',?,?,?)",[$actor,hash('sha256',json_encode($r)),json_encode($rows),DB::revision()]);
|
||||
Csv::apply((int)DB::conn()->lastInsertId(),$actor);
|
||||
return DB::one('SELECT * FROM matches WHERE fff_match_id=? AND team_id=1',[$r['numero_match']]);
|
||||
}
|
||||
$r=['numero_match'=>'TEST-VENUE','equipe_locale_1'=>'BEAUMONT ST CYR ES 1','equipe_adverse_1'=>'ADVERSAIRE 1','recevant_visiteur_1'=>'Recevant','date_du_match_1'=>'2026-10-04','heure_du_match_1'=>'13H00','nom_de_l_installation_1'=>" STADE MICHEL BREMAUD 1\u{00A0} "];
|
||||
$m=importVenue($r,$actor);checkVenue($m['venue']==='STADE MICHEL BREMAUD 1','Nom Footclubs nettoyé et enregistré');
|
||||
$id=$m['id'];$r['nom_de_l_installation_1']='STADE MICHEL BREMAUD 2';$m=importVenue($r,$actor);checkVenue($m['id']===$id&&$m['venue']==='STADE MICHEL BREMAUD 2','Réimport actualise le terrain sans doublon');
|
||||
$r['nom_de_l_installation_1']='';$m=importVenue($r,$actor);checkVenue($m['venue']==='STADE MICHEL BREMAUD 2','Export sans terrain conserve l’affectation');
|
||||
$m['short_name']='E1';$b=array_replace($m,['id'=>999,'short_name'=>'E4','venue'=>'STADE MICHEL BREMAUD 1']);$s=ClubSettings::DEFAULTS;
|
||||
checkVenue(!CalendarAlerts::compute([$m,$b],$s),'Deux installations distinctes au même horaire acceptées');
|
||||
$m['venue']='';checkVenue((bool)CalendarAlerts::compute([$m,$b],$s),'Terrain par défaut identique reconnu malgré les espaces');
|
||||
$b['match_time']='15:00:00';checkVenue(!CalendarAlerts::compute([$m,$b],$s),'13 h et 15 h sur le terrain 1 acceptés');
|
||||
Reference in New Issue
Block a user