Files
Investidor-V2/outputs/investmoz-audit-current-20261012/business-country-fixture.php
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

21 lines
3.5 KiB
PHP

<?php
// Fixture only in the existing guarded consumers QA. A published fixture is not a publication-workflow proof.
ini_set('zend.exception_ignore_args','1');set_exception_handler(function(Throwable $e){fwrite(STDERR,json_encode(['error_type'=>$e::class,'line'=>$e->getLine(),'values_recorded'=>false]));exit(1);});
$root=dirname(__DIR__,2);$private=$root.'/storage/app/private/investmoz-v2/portal-audit';$plan=json_decode(file_get_contents($private.'/portal-stability-latest.json'),true,512,JSON_THROW_ON_ERROR);$qa=$plan['source'];
if(!str_starts_with(str_replace('\\','/',$qa),str_replace('\\','/',$private).'/')||basename($qa)!=='portal-stability-source-20261011_083742')throw new RuntimeException('QA source refused');
putenv('STABILITY_QA_MODE=consumers');$app=require $qa.'/tools/portal-stability-runtime.php';$c=config('database.connections.'.config('database.default'));
if($c['database']!=='stability_consumers_20261011_084534_test'||(int)$c['port']!==55441||!empty($c['url']))throw new RuntimeException('Active writing refused');
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$db=Illuminate\Support\Facades\DB::connection();$identity=(array)$db->selectOne('SELECT current_database() AS database,inet_server_port() AS port');if($identity['database']!==$c['database']||(int)$identity['port']!==55441)throw new RuntimeException('Actual target refused');
if(config('portal.notifications_enabled'))throw new RuntimeException('QA notifications must stay disabled');
$path=__DIR__.'/business-country-fixture.json';$slug='qa-business-country-audit-20261012';$existing=App\Models\ExistingBusiness::withTrashed()->where('public_slug',$slug)->first();$mode=$argv[1]??'--read';
if($mode==='--prepare'&&!$existing){
$actors=json_decode(file_get_contents($private.'/profiles-v1-actors-private.json'),true,512,JSON_THROW_ON_ERROR);$a=$actors['promoter'];$uid=$a['id']??$a['actor_id']??$a['user_id'];$u=App\Models\User::findOrFail($uid);if($u->email!==$a['email']||!$u->hasVerifiedEmail())throw new RuntimeException('Synthetic actor correspondence differs');
$existing=app(App\Services\ExistingBusinessDrafts::class)->save($u,['modality'=>'company_sale','classification'=>'restricted','public_title'=>'Anúncio sintético QA — países e origem','reason'=>'Fixture sintética da auditoria; não é prova de aprovação/publicação operacional',
'payload'=>['title'=>'Anúncio sintético QA — países e origem','description'=>'Dados exclusivamente sintéticos para ensaiar manifestações, países e origem nesta base QA isolada.','source_reference'=>'Auditoria QA 12/10/2026; fixture explicitamente sintética','country'=>'MZ','declared_origin_country_code'=>'PT']]);
// Explicit setup for the consumer under test. No claim about the separate existing-business workflow.
$existing->forceFill(['status'=>'published','public_slug'=>$slug,'published_at'=>now()->subMinute()])->save();
}elseif($mode!=='--prepare'&&$mode!=='--read')throw new RuntimeException('Unknown mode');
if(!$existing)throw new RuntimeException('Fixture not prepared');
$proof=['at'=>gmdate('c'),'target'=>$identity,'QA_source'=>$qa,'business_id'=>$existing->id,'slug'=>$slug,'URL'=>'https://portal-investidor.test:18445/negocios/'.$slug.'/manifestar-interesse','synthetic_fixture'=>true,'draft_service_reused'=>true,'published_state_prepared_fixture_not_workflow_proof'=>true,'active_writes'=>0,'external_notifications_enabled'=>false];
file_put_contents($path,json_encode($proof,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo json_encode($proof);