36 lines
3.6 KiB
PHP
36 lines
3.6 KiB
PHP
<?php
|
|
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
|
|
$b5Root=dirname(__DIR__,2);$b5QA=$b5Root.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';
|
|
$app=require $b5QA.'/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');
|
|
if(config('portal.notifications_enabled')||config('suitecrm.enabled'))throw new RuntimeException('External notifications must remain off');
|
|
$digest=function($table)use($db){$rows=$db->table($table)->get()->map(fn($row)=>json_encode($row,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);
|
|
$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);
|
|
$validator=Illuminate\Support\Facades\Validator::make($input,$r->rules());$validator->validate();$r->setValidator($validator);
|
|
return $r;
|
|
};
|
|
$controller=app(App\Http\Controllers\LandAssistanceController::class);
|
|
$payload=['support_kind'=>'investment','request_description'=>'SIMULAÇÃO QA B5: apoio requerido por entidade, sem direito ou decisão externa.',
|
|
'applicant_category'=>'entity','full_name'=>'Entidade fictícia QA B5','email'=>'scope-b5-entity@example.invalid','country'=>'ZA','declared_origin_country_code'=>'PT',
|
|
'representative_name'=>'Representante sintético QA','representation_basis'=>'Designação exclusivamente sintética QA','truth_declaration'=>true,'contact_consent'=>true];
|
|
$created=$controller->store($make('/investidor/terra-duat',['payload'=>$payload]));$id=$created->getData(true)['id'];
|
|
$controller->requestSupport($make('/investidor/terra-duat/'.$id.'/solicitar-apoio',['version'=>1,'payload'=>$payload]),$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!=='individual')throw new RuntimeException('Expected before defect no longer present; do not patch blindly');
|
|
$proof=['at'=>gmdate('c'),'target'=>$target,'active_writes'=>0,'browser_observed'=>false,'proof_level'=>'Controller and SQL in outer rolled-back QA transaction; not a web-server HTTP observation',
|
|
'operation'=>'POST /investidor/terra-duat/{id}/solicitar-apoio','applicant_category'=>'entity','expected_investor_type'=>'empresa','observed_investor_type'=>$interest->investor_type,
|
|
'country'=>'ZA','declared_origin'=>'PT','cause'=>'requestSupport factory hardcodes investor_type=individual regardless of declared applicant category','result'=>'defect_reproduced',
|
|
'no_persisted_fixture_from_before'=>true];
|
|
}finally{$db->rollBack();}
|
|
foreach($before as$t=>$hash)if(!hash_equals($hash,$digest($t)))throw new RuntimeException('Rolled-back reproduction changed data');
|
|
$proof['all_rolled_back_tables_preserved']=true;
|
|
$dest=__DIR__.'/option-B5-land-entity-before.json';if(is_file($dest))throw new RuntimeException('Preserve before 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;
|