6 lines
2.4 KiB
PHP
6 lines
2.4 KiB
PHP
<?php
|
|
$id=$db->table('purchase_orders')->where('tenant_id',$n['tenant'])->value('id');$invoice=$db->table('invoices')->where('status','validated')->orderBy('id')->value('id');$url=$base.'/orders/'.$id;$before=hash('sha256',json_encode([$db->table('invoices')->orderBy('id')->get(),$db->table('budget_consumptions')->orderBy('id')->get(),$db->table('audit_logs')->orderBy('id')->get()]));$preview=function()use($call,$url,$invoice){$state=$call('reviewer',$url);$p=$call('reviewer',$url.'/preview',['operation_key'=>(string)Illuminate\Support\Str::uuid(),'revision'=>$state['data']['revision'],'action'=>'validate','reason'=>'Sonda de fronteira sem repetir a decisão validada.','data'=>['invoice_id'=>$invoice]]);if($p['status']!==200)throw new RuntimeException('Original idempotent validation preview unavailable');return $p['data']['preview'];};$confirm=fn($cut)=>$call('reviewer',$url.'/confirm',['preview'=>$cut]);
|
|
$cut=$preview();$enter('reviewer');$ok($confirm($cut)['status']===409,'new session context generation invalidates invoice preview');$cut=$preview();$version=$db->table('suppliers')->where('id',$n['supplier_ids'][0])->value('version');$db->table('suppliers')->where('id',$n['supplier_ids'][0])->update(['version'=>$version+1]);try{$ok($confirm($cut)['status']===409,'supplier source version change requires new matching preview');}finally{$db->table('suppliers')->where('id',$n['supplier_ids'][0])->update(['version'=>$version]);}
|
|
$cut=$preview();$file=$s['root'].'/binding.json';$bytes=file_get_contents($file);$profile=json_decode($bytes,true);$key=implode(':',array_values($f['scope'])).':'.$f['reviewer'];$profile['bindings'][$key]['warehouse_ids'][]=999999;file_put_contents($file,json_encode($profile));try{$ok($confirm($cut)['status']===409,'changed source binding invalidates invoice preview');}finally{file_put_contents($file,$bytes);}
|
|
$after=hash('sha256',json_encode([$db->table('invoices')->orderBy('id')->get(),$db->table('budget_consumptions')->orderBy('id')->get(),$db->table('audit_logs')->orderBy('id')->get()]));$ok($before===$after,'boundary probes persist no revalidation audit consumption or invoice change');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'before'=>$before,'after'=>$after,'valid45_checks_not_repeated'=>true,'probe'=>'rollback-only original idempotent validation preview and rejected confirmations'],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." invoice boundary checks passed.\n";
|