publicReferences()->where('location_type', 'province')->where('name', 'Inhambane')->first(); if (! $province) { // Tests must not depend on an operational import. These placeholders exist // only in the already isolated test database and caller's rollback transaction. if (DB::transactionLevel() < 1) { throw new \LogicException('Synthetic references require test rollback'); } $country = (string) Str::uuid(); $id = (string) Str::uuid(); foreach ([[$country, 'country', null, 'Synthetic QA country'], [$id, 'province', $country, 'Inhambane']] as [$key, $type, $parent, $name]) { DB::table('geo_locations')->insert(['id' => $key, 'code' => 'SYNTHETIC-QA-'.$key, 'name' => $name, 'location_type' => $type, 'parent_id' => $parent, 'data_classification' => 'public', 'source_system' => 'cartografia-workbook', 'external_id' => '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:'.$key]); } $province = app(InvestmentGeography::class)->publicReferences()->where('id', $id)->first(); } $sector = Sector::where('slug', 'turismo')->first(); if (! $sector) { if (DB::transactionLevel() < 1) { throw new \LogicException('Synthetic sector requires test rollback'); } $sector = Sector::create(['slug' => 'turismo', 'name' => 'Synthetic QA tourism', 'is_active' => true]); } $editor = User::factory()->create(); $reviewer = User::factory()->create(); $zone = InvestmentZone::query()->create(['id' => (string) Str::uuid(), 'code' => 'SINT-QA-'.Str::random(8), 'name' => 'SINTÉTICO QA — Parque Industrial de Balama', 'category' => 'industrial_park', 'physical_category' => 'industrial_park', 'publication_status' => 'published', 'validation_status' => 'validated', 'editor_id' => $editor->id, 'reviewer_id' => $reviewer->id, 'published_at' => now(), 'source_evidence' => [['source_type' => 'promoter', 'url' => 'https://example.invalid/synthetic-qa', 'supports' => 'SINTÉTICO QA: não constitui informação sobre o parque real.']]]); $other = InvestmentZone::query()->create(['id' => (string) Str::uuid(), 'code' => 'SINT-QA-'.Str::random(8), 'name' => 'SINTÉTICO QA — Outro parque', 'category' => 'industrial_park', 'physical_category' => 'industrial_park', 'publication_status' => 'published', 'validation_status' => 'validated', 'editor_id' => $editor->id, 'reviewer_id' => $reviewer->id, 'published_at' => now(), 'source_evidence' => [['source_type' => 'promoter', 'url' => 'https://example.invalid/synthetic-qa', 'supports' => 'SINTÉTICO QA: outra associação.']]]); $prefix = 'SINTÉTICO QA turismo '.Str::upper(Str::random(8)); $create = function (string $name, string $purpose, string $currency, int $level, ?string $stage = null, ?string $target = null, bool $private = false) use ($sector, $province, $zone, $prefix) { $row = ['related_id' => $target ?? $zone->id, 'relation_type' => 'located_in', 'classification' => ['target_type' => 'park', 'purpose' => $purpose, 'disclosure' => 'public', 'requested_state' => 'preliminary', 'source_reference' => 'SINTÉTICO QA — ensaio de pesquisa', 'citation' => 'Fixture local']]; return Opportunity::forceCreate(['reference' => 'SINT-QA-'.Str::random(10), 'slug' => 'sintetico-qa-'.Str::uuid(), 'title' => $prefix.' '.$name, 'summary' => 'Dados sintéticos para ensaio exclusivo em QA.', 'sector_id' => $sector->id, 'province' => 'Inhambane', 'primary_territory_id' => $province->id, 'maturity_level' => $level, 'maturity_label' => $stage ? OpportunityMaturity::STAGES[$stage] : OpportunityMaturity::LEGACY_LABELS[$level], 'estimated_investment_amount' => '300000.00', 'estimated_investment_currency' => $currency, 'opportunity_category' => 'investment_project', 'status' => $private ? 'draft' : 'published', 'published_at' => $private ? null : now(), 'workflow_context' => ['publication' => ['visibility' => 'public', 'classification' => [$row], 'maturity' => ['catalogue_version' => $stage ? OpportunityMaturity::VERSION : OpportunityMaturity::LEGACY, 'stage' => $stage]]]]); }; return ['query' => $prefix, 'zone' => $zone, 'other_zone' => $other, 'province' => $province, 'associated' => $create('associada', 'park_operation', 'USD', 2), 'nearby' => $create('apenas próxima', 'proximity', 'USD', 2, 'concept'), 'same_territory' => $create('mesmo território', 'administrative_boundary', 'MZN', 4, 'feasibility'), 'other_park' => $create('outro parque', 'park_operation', 'USD', 4, 'feasibility', $other->id), 'private' => $create('privada', 'park_operation', 'USD', 2, null, null, true)]; } }