fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -15,35 +15,42 @@ final class OpportunitySearchFixture
|
||||
{
|
||||
public static function create(): array
|
||||
{
|
||||
if (! IsolatedQaDatabase::allowsSchemaChanges()) throw new \LogicException('Isolated QA only');
|
||||
if (! IsolatedQaDatabase::allowsSchemaChanges()) {
|
||||
throw new \LogicException('Isolated QA only');
|
||||
}
|
||||
$province = app(InvestmentGeography::class)->publicReferences()->where('location_type', 'province')->where('name', 'Inhambane')->first();
|
||||
if (! $province) throw new \LogicException('QA requires the existing public Inhambane reference');
|
||||
if (! $province) {
|
||||
throw new \LogicException('QA requires the existing public Inhambane reference');
|
||||
}
|
||||
$sector = Sector::where('slug', 'turismo')->firstOrFail();
|
||||
$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]]]]);
|
||||
$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)];
|
||||
|
||||
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)];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user