42 lines
4.9 KiB
PHP
42 lines
4.9 KiB
PHP
<?php
|
|
|
|
use App\Models\InvestmentDossier;
|
|
use App\Models\SimulationFormDraft;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\Str;
|
|
|
|
if (! defined('INVESTMOZ_V2_QA') || ! INVESTMOZ_V2_QA || DB::connection()->getDatabaseName() !== 'investmoz_v2_20261008_test' || (string) DB::connection()->getConfig('port') !== '55441') {
|
|
throw new RuntimeException('V2 fixtures are restricted to the isolated database.');
|
|
}
|
|
$owner = User::where('email', 'guidance-qa-investor@example.invalid')->firstOrFail();
|
|
$manager = User::where('email', 'guidance-qa-manager@example.invalid')->firstOrFail();
|
|
DB::table('desk_institutional_links')->insertOrIgnore(['id' => '00000000-0000-4000-8000-000000000303', 'stage' => 'E10',
|
|
'entity' => 'Instituição sintética V2 QA', 'purpose' => 'Monitoria de disponibilidade QA', 'url' => 'https://example.invalid/',
|
|
'contact' => 'Contacto sintético QA; não utilizar fora dos testes', 'source_reference' => 'Fixture QA, não é fonte institucional', 'status' => 'pending']);
|
|
foreach (['project' => 'projects', 'cluster' => 'economic_clusters'] as $kind => $table) {
|
|
$entity = DB::table($table)->where('code', 'V2-QA-'.strtoupper($kind))->value('id');
|
|
if (! $entity) {
|
|
$entity = (string) Str::uuid();
|
|
DB::table($table)->insert(['id' => $entity, 'code' => 'V2-QA-'.strtoupper($kind), 'name' => 'V2 QA '.$kind, 'status' => $kind === 'cluster' ? 'planned' : 'draft', 'data_classification' => 'public', ...($kind === 'cluster' ? ['sector' => 'Sector fictício QA'] : [])]);
|
|
}
|
|
InvestmentDossier::firstOrCreate([$kind.'_id' => $entity], ['title' => 'V2 QA '.$kind, 'source' => 'Fixture sintética exclusiva da QA, sem aprovação institucional.', 'content' => ['code' => 'V2-QA-'.strtoupper($kind), 'description' => 'Registo fictício para pesquisa e ficha.'], 'publication_status' => 'published', 'published_at' => now(), 'editor_id' => $owner->id, 'reviewer_id' => $manager->id, 'approval_basis' => 'manager', 'approval_evidence' => 'Apenas fixture QA; não representa acto real.']);
|
|
}
|
|
if (! DB::table('investment_zones')->where('code', 'V2-QA-PARK')->exists()) {
|
|
DB::table('investment_zones')->insert(['id' => (string) Str::uuid(), 'code' => 'V2-QA-PARK', 'name' => 'V2 QA localização fictícia', 'name_en' => 'V2 QA fictional location', 'description_en' => 'Synthetic QA only, not an institutionally approved location.', 'category' => 'industrial_park', 'physical_category' => 'industrial_park', 'legal_regime' => 'pending', 'description' => 'Fixture para pesquisa; disponibilidade e regime não confirmados.', 'publication_status' => 'published', 'validation_status' => 'validated', 'source_evidence' => json_encode([['source_type' => 'promoter', 'title' => 'Fixture QA — não é fonte institucional', 'url' => 'https://example.invalid/qa', 'supports' => 'Apenas a ficha fictícia usada no ensaio.']]), 'availability_status' => 'not_informed', 'editor_id' => $owner->id, 'reviewer_id' => $manager->id, 'published_at' => now()]);
|
|
}
|
|
SimulationFormDraft::firstOrCreate(['id' => '00000000-0000-4000-8000-000000000202'], ['owner_user_id' => $owner->id, 'version_no' => 1, 'create_key_hash' => hash('sha256', 'v2-qa-existing-key'), 'create_payload_hash' => hash('sha256', 'v2-qa-existing-data'), 'snapshot_sha256' => hash('sha256', 'v2-qa-existing-data'), 'economic_snapshot' => SimulationFormDraft::encryptSnapshot(['project_title' => 'V2 QA rascunho anterior', 'project_summary' => 'Ideia anterior preservada QA', 'products_services' => 'Transformação fictícia QA', 'market_source' => 'Declaração fictícia, por conferir']), 'personal_snapshot' => SimulationFormDraft::encryptSnapshot([])]);
|
|
if (isset($argv[2])) {
|
|
$case = DB::table('desk_cases')->where('id', $argv[2])->where('user_id', $owner->id)->firstOrFail();
|
|
if (! DB::table('desk_documents')->where('case_id', $case->id)->where('source_reference', 'Fixture V2 QA; scan simulated by test double')->exists()) {
|
|
$bytes = 'Ficheiro sintetico V2 QA. Apenas acesso descrito neste texto ficticio, nao disponibilidade nem licenca.';
|
|
$key = 'v2-qa-browser/'.$case->id.'.txt';
|
|
Storage::disk('local')->put($key, $bytes);
|
|
$hash = hash('sha256', $bytes);
|
|
$document = (string) Str::uuid();
|
|
DB::table('documents')->insert(['id' => $document, 'source_system' => 'v2-qa-test-double', 'file_name' => 'Evidencia V2 QA.txt', 'media_type' => 'text/plain', 'storage_key' => $key, 'sha256' => $hash, 'size_bytes' => strlen($bytes), 'uploaded_by' => $owner->id, 'status' => 'active', 'data_classification' => 'confidential', 'malware_scan_status' => 'clean', 'malware_engine' => 'QA-Test-Double', 'malware_scanned_sha256' => $hash]);
|
|
DB::table('desk_documents')->insert(['id' => (string) Str::uuid(), 'case_id' => $case->id, 'document_id' => $document, 'category' => 'location_evidence', 'source_reference' => 'Fixture V2 QA; scan simulated by test double', 'linked_by' => $owner->id]);
|
|
}
|
|
}
|