Files
SGF/scripts/sgf-payable-due-pagination-proof.php
T
2026-11-11 09:00:17 +02:00

7 lines
1.7 KiB
PHP

<?php
require __DIR__.'/sgf-payable-due-proof-bootstrap.php';$last=$native->table('pd_due_versions')->orderByDesc('id')->first();$id=(int)$last->obligation_id;$before=$native->table('pd_due_versions')->orderBy('id')->get()->toJson();$initial=$native->table('pd_due_versions')->where('obligation_id',$id)->count();$native->beginTransaction();try{
for($i=0;$i<29;$i++){$row=(array)$last;unset($row['id']);$row['version']++;$row['previous_id']=$last->id;$row['reason']='Fixture SQL de histórico apenas; não é decisão de negócio executada.';$new=$native->table('pd_due_versions')->insertGetId($row);$last=(object)($row+['id'=>$new]);}
$query=['obligation_id'=>$id,'reference_on'=>'2026-11-30'];$first=$dueCall(17,'index',$query+['per_page'=>25]);$second=$dueCall(17,'index',$query+['per_page'=>25,'page'=>2]);$large=$dueCall(17,'index',$query+['per_page'=>100]);$a=$first['value']['history'];$b=$second['value']['history'];$c=$large['value']['history'];$ok(count($a['data'])===25&&count($b['data'])===$initial+4,'history truly crosses25 boundary');$ok(array_column(array_merge($a['data'],$b['data']),'id')===array_column($c['data'],'id'),'ordered25 pages equal100 without omission or duplicate');$ok($a['total']===$initial+29&&$c['total']===$a['total'],'SQL total equals scoped fixture set');
}finally{while($native->transactionLevel()>0)$native->rollBack();}
$ok($native->table('pd_due_versions')->orderBy('id')->get()->toJson()===$before,'history fixtures rolled back');file_put_contents($work.'/payable-due-pagination.json',json_encode(['passed'=>true,'checks'=>$checks,'sql_history_fixtures'=>29,'business_commands'=>0,'fixtures_rolled_back'=>true],JSON_PRETTY_PRINT));echo json_encode(['passed'=>true,'checks'=>count($checks),'proof'=>$work.'/payable-due-pagination.json']).PHP_EOL;