28 lines
3.9 KiB
PHP
28 lines
3.9 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
|
|
$app=require dirname(__DIR__,2).'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742/tools/portal-stability-runtime.php';
|
|
$db=Illuminate\Support\Facades\DB::connection();$target=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');
|
|
if($target!==['database'=>'stability_consumers_20261011_084534_test','port'=>55441])throw new RuntimeException('QA only');
|
|
$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
|
|
try{
|
|
$prior=json_decode(file_get_contents(__DIR__.'/option-B-next-preflight.json'),true,512,JSON_THROW_ON_ERROR);$preserved=[];
|
|
$newTasks=$db->table('tasks')->where('created_at','>=',$prior['at'])->get(['id','external_id','source_system','due_at','status']);
|
|
foreach($prior['protected_tables']as$name=>$before){$query=$db->table($name);if($name==='tasks')$query->whereNotIn('id',$newTasks->pluck('id'));$rows=$query->get();$bytes=$rows->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($bytes,SORT_STRING);$preserved[$name]=$rows->count()===$before['count']&&hash('sha256',implode("\n",$bytes))===$before['sha256'];}
|
|
if(in_array(false,$preserved,true)||$newTasks->count()!==6)throw new RuntimeException('Unexpected preserved-data or task changes');
|
|
foreach($newTasks as$t)if($t->source_system!=='opportunity-workflow'||!str_starts_with($t->external_id,'portal-opportunity:32:')||$t->due_at!==null)throw new RuntimeException('Unexpected task scope or deadline');
|
|
$o=App\Models\Opportunity::findOrFail(32);$c=app(App\Services\OpportunityManagement::class)->values($o)['canonical'];$parcel=$c['land_rights']['parcels'][0];
|
|
$orig=json_decode(file_get_contents(__DIR__.'/option-B2-resource-original.json'),true,512,JSON_THROW_ON_ERROR);$loc=$db->table('opportunity_location_drafts')->where('id',$orig['resource_id'])->where('opportunity_id',32)->first();$payload=json_decode($loc->payload,true,512,JSON_THROW_ON_ERROR);
|
|
$expected=$orig['original_payload'];$expected['area_value']=1100;$expected['area_unit']='sqm';
|
|
if(Illuminate\Support\Arr::sortRecursive($payload)!==Illuminate\Support\Arr::sortRecursive($expected)||(int)$loc->version!==(int)$orig['original_version']+3||(float)$parcel['area']!==1100.0||$parcel['area_unit']!=='sqm'||$o->workflow_context['working_state']!=='published')throw new RuntimeException('Area/recovery differs');
|
|
$cond=$o->workflow_context['conditions']['e2752052-b5ab-42da-a43a-c494b71fe32c'];if($cond['status']==='open')throw new RuntimeException('Required condition still open');
|
|
$p=['at'=>gmdate('c'),'target'=>$target,'SQL_read_only'=>true,'active_writes'=>0,
|
|
'protected_tables_preserved'=>$preserved,'prior_tasks_preserved'=>$prior['protected_tables']['tasks']['count'],
|
|
'new_tasks'=>6,'tasks_only_case32_without_due_dates'=>true,'same_location_id'=>$loc->id,'location_version_increment'=>3,
|
|
'area'=>1100,'explicit_unit'=>'sqm','other_location_metadata_preserved'=>true,'numeric_area_not_converted'=>true,
|
|
'state'=>'published','visibility'=>$o->workflow_context['publication']['visibility'],
|
|
'existing_internal_condition_reverified'=>true,'condition_resolution_history_preserved'=>count($cond['resolution_history'])===1&&$cond['resolution_history'][0]['content_revision']===6&&$cond['resolution_history'][0]['at']==='2026-10-11T11:40:05+00:00',
|
|
'current_condition_resolution_recorded_separately'=>isset($cond['resolution'])&&$cond['resolution']['actor_id']===24&&$cond['resolution']['scope']==='internal_verification_not_external_decision',
|
|
'path_available'=>app(App\Services\InvestorPath::class)->available(),'notifications'=>config('portal.notifications_enabled')];
|
|
$path=__DIR__.'/option-B2-final-QA.json';if(is_file($path))throw new RuntimeException('Preserve final proof');file_put_contents($path,json_encode($p,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($p).PHP_EOL;
|
|
}finally{$db->rollBack();}
|