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'); if(config('portal.notifications_enabled')||config('suitecrm.enabled'))throw new RuntimeException('No external notifications'); $digest=function($t)use($db){$rows=$db->table($t)->get()->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($rows,SORT_STRING);return hash('sha256',implode("\n",$rows));}; $before=[];foreach(['land_assistance_cases','interest_requests','interest_submission_receipts','outbox_events','consents','audit_events']as$t)$before[$t]=$digest($t); $proof=['at'=>gmdate('c'),'target'=>$target,'active_writes'=>0,'proof_level'=>'Controller/SQL in rolled-back QA transaction; entity also independently proven by normal web HTTP','browser_observed'=>false,'cases'=>[]]; $db->beginTransaction(); try{ $actor=App\Models\User::findOrFail(21); $make=function($path,$input)use($actor,$app){$r=App\Http\Requests\StoreLandAssistanceCaseRequest::create($path,'POST',$input,[],[],['HTTP_ACCEPT'=>'application/json']);$r->setContainer($app);$r->setUserResolver(fn()=>$actor);$v=Illuminate\Support\Facades\Validator::make($input,$r->rules());$r->withValidator($v);$v->validate();$r->setValidator($v);return$r;}; $controller=app(App\Http\Controllers\LandAssistanceController::class); foreach(['individual'=>'individual','entity'=>'empresa','community'=>'outro','other'=>'outro']as$category=>$expected){ $payload=['support_kind'=>'investment','request_description'=>'SIMULAÇÃO QA B5: classificação do apoio sem decisão externa.', 'applicant_category'=>$category,'full_name'=>'Requerente fictício QA B5','email'=>'scope-b5-classification@example.invalid','country'=>'ZA','declared_origin_country_code'=>'PT', 'preferred_contact'=>'email','purpose'=>'Preparação sintética QA','truth_declaration'=>true,'contact_consent'=>true]; $created=$controller->store($make('/investidor/terra-duat',['payload'=>$payload]));$id=$created->getData(true)['id']; $r=$make('/investidor/terra-duat/'.$id.'/solicitar-apoio',['version'=>1,'payload'=>$payload]); $controller->requestSupport($r,$id,app(App\Services\InterestSubmission::class)); $case=App\Models\LandAssistanceCase::findOrFail($id);$interest=App\Models\InterestRequest::findOrFail($case->interest_request_id); if($interest->investor_type!==$expected||($interest->metadata['applicant_category']??null)!==$category)throw new RuntimeException('Incorrect category mapping'); $controller->requestSupport($r,$id,app(App\Services\InterestSubmission::class)); if($db->table('interest_requests')->where('metadata->land_case_id',$id)->count()!==1)throw new RuntimeException('Duplicate'); $proof['cases'][]=['category'=>$category,'intake_type'=>$expected,'original_category_in_metadata'=>true,'repeat_same_receipt'=>true]; } }finally{$db->rollBack();} foreach($before as$t=>$hash)if(!hash_equals($hash,$digest($t)))throw new RuntimeException('Unexpected persisted changes'); $proof['transaction_rolled_back_and_records_preserved']=true;$proof['result']='passed'; $dest=__DIR__.'/option-B5-land-classifications.json';if(is_file($dest))throw new RuntimeException('Preserve evidence'); file_put_contents($dest,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));echo json_encode($proof,JSON_UNESCAPED_UNICODE).PHP_EOL;