Files
ESBSC-CONVOC/tests/convocations_spond.php
T
2026-11-11 09:24:28 +01:00

28 lines
1.6 KiB
PHP

<?php
// Isolated rendering regression: real template and Spond code, database rows supplied by fixture.
namespace App {
final class DB {
public static array $rows=[];
public static function all(string $sql,array $args=[]):array {
if($args!==['2026-09-28'])throw new \RuntimeException('Semaine incorrecte');
return self::$rows;
}
}
}
namespace {
require dirname(__DIR__).'/bootstrap.php';
set_error_handler(function($n,$s,$f,$l){throw new ErrorException($s,0,$n,$f,$l);});
$id=1;$week='2026-09-28';
$summary=['week'=>$week,'end'=>'2026-10-04','groups'=>[],'missing'=>[['id'=>$id,'last_name'=>'TEST','first_name'=>'Spond','discipline'=>[]]],'availability'=>[]];
function renderConvocations(array $summary,?array $provided=null):string{
$_SESSION['csrf']='test-token';$user=['role'=>'viewer'];if($provided!==null)$spond=$provided;
ob_start();try{require dirname(__DIR__).'/templates/convocations.php';return ob_get_contents();}finally{ob_end_clean();}
}
if(!str_contains(renderConvocations($summary),'Spond : Non renseigné'))throw new RuntimeException('Sans import');
\App\DB::$rows=[['player_id'=>1,'match_id'=>null,'status'=>'present','responded_at'=>null,'imported_at'=>'2026-10-02 14:00:00']];
if(!str_contains(renderConvocations($summary),'Spond : Présent'))throw new RuntimeException('Disponibilité non chargée');
$given=[$id=>['status'=>'absent','answers'=>[]]];
if(!str_contains(renderConvocations($summary,$given),'Spond : Absent'))throw new RuntimeException('Contexte fourni non conservé');
echo "OK : variable absente sans import, avec réponse, et contexte fourni. Aucun avertissement PHP.\n";
}