Files
Investidor-V2/outputs/investmoz-audit-current-20261012/option-B7-business-preflight.php
T
nala ba1c0340ea
tests / ci (push) Canceled after 0s
oportunidades 8
2026-10-14 08:25:30 +02:00

18 lines
2.9 KiB
PHP

<?php
ini_set('zend.exception_ignore_args','1');putenv('STABILITY_QA_MODE=consumers');
$b7Root=dirname(__DIR__,2);$b7QA=$b7Root.'/storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';
$app=require$b7QA.'/tools/portal-stability-runtime.php';$db=Illuminate\Support\Facades\DB::connection();
$t=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');
if($t!==['database'=>'stability_consumers_20261011_084534_test','port'=>55441])throw new RuntimeException('QA only');
$db->beginTransaction();$db->statement('SET TRANSACTION READ ONLY');
try{
$proof=['at'=>gmdate('c'),'target'=>$t,'SQL_read_only'=>true,'active_writes'=>0,'flags'=>['profile_access'=>app(App\Services\PortalProfileAccess::class)->available(),'business'=>config('existing-business.enabled'),'notifications'=>config('portal.notifications_enabled'),'shadow'=>config('existing-business.compatibility_shadow')],'actors'=>[],'protected_tables'=>[]];
if(!$proof['flags']['profile_access']||!$proof['flags']['business']||$proof['flags']['notifications']||$proof['flags']['shadow'])throw new RuntimeException('QA prerequisites differ');
foreach([21,22,23,24,25,26,27,31]as$id){$u=App\Models\User::findOrFail($id);if(!str_ends_with($u->email,'.invalid'))throw new RuntimeException('Synthetic actor required');$proof['actors'][]=['id'=>$id,'manage_portal'=>$u->can('manage-portal'),'verified'=>$u->hasVerifiedEmail(),'grants'=>array_map(fn($g)=>['role'=>$g->role,'organization_id'=>$g->organization_id,'types'=>json_decode($g->opportunity_types,true)],app(App\Services\PortalProfileAccess::class)->grants($u))];}
foreach(['users','organizations','memberships','portal_role_assignments','portal_superuser_pair','opportunities','documents','opportunity_documents','opportunity_images','opportunity_locations','desk_requests','desk_documents','investor_journeys','journey_steps','investment_submissions','jobs','existing_businesses','business_workflow_transitions','existing_business_revisions','tasks','outbox_events']as$table){$rows=$db->table($table)->get();$bytes=$rows->map(fn($r)=>json_encode($r,JSON_THROW_ON_ERROR))->all();sort($bytes,SORT_STRING);$proof['protected_tables'][$table]=['count'=>$rows->count(),'sha256'=>hash('sha256',implode("\n",$bytes))];}
$proof['existing_businesses']=$db->table('existing_businesses')->get(['id','modality','owner_user_id','status','version_no']);
$proof['legacy_state_chain_preserved']=['draft','submitted','triage','in_review','needs_information','approval_l1','approval_l2','approved','published'];
$dest=__DIR__.'/option-B7-business-preflight.json';if(is_file($dest))throw new RuntimeException('Preserve preflight');file_put_contents($dest,json_encode($proof,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_THROW_ON_ERROR));
echo json_encode(array_diff_key($proof,['protected_tables'=>true]),JSON_UNESCAPED_UNICODE).PHP_EOL;
}finally{$db->rollBack();}