withoutVite();} public function test_public_sector_is_consultable_by_guest_and_accounts_without_promoter_grants():void { config(['portal.homologation_only'=>false,'portal.legacy_content_enabled'=>false,'portal.legacy_content_qa_enabled'=>false]); $this->get('/sectores/turismo')->assertOk(); $actor=User::factory()->create(); $this->actingAs($actor)->get('/sectores/turismo')->assertOk(); $this->assertSame(0,DB::table('portal_role_assignments')->where('user_id',$actor->id)->count()); config(['portal.profile_access_enabled'=>true]); $entry=app(\App\Services\SectorInvestment::class)->publicView(\App\Models\Sector::where('slug','turismo')->firstOrFail()); $this->assertSame('/perfil/promotor',$entry['register_href']); $this->assertSame('Pedir acesso para cadastrar oportunidades',$entry['register_label']); } public function test_zones_all_equals_visible_set_and_province_and_district_never_fall_back_to_all():void { $zones=app(InvestmentZones::class);$geo=app(InvestmentGeography::class); $province='059b02ca-7095-577a-8705-4d4c46896747'; $district=$geo->publicReferences()->where('parent_id',$province)->where('location_type','district')->first(); $template=$zones->visible()->firstOrFail(); $make=function($territory,$published=true)use($template){$zone=$template->replicate();$zone->id=(string)Str::uuid();$zone->code='SYNTHETIC-'.Str::random(12);$zone->name='SYNTHETIC QA zone scope';$zone->primary_territory_id=$territory;$zone->publication_status=$published?'published':'draft';$zone->save();return$zone;}; $inside=$make($district->id);$outside=$make('9e42dac8-fd9b-523f-bf59-71a7d3aa0fb8');$private=$make($district->id,false); $all=$zones->search([])->orderBy('id')->pluck('id')->all(); $this->assertSame($zones->visible()->orderBy('id')->pluck('id')->all(),$all); foreach([['province_id'=>$province],['province_id'=>$province,'district_id'=>$district->id]]as$selection){ $ids=$zones->search($selection)->pluck('id')->all(); $this->assertContains($inside->id,$ids);$this->assertNotContains($outside->id,$ids);$this->assertNotContains($private->id,$ids); } } public function test_documented_legal_scope_covers_child_area_but_influence_does_not_become_an_installation():void { $zones=app(InvestmentZones::class);$geo=app(InvestmentGeography::class);$province='059b02ca-7095-577a-8705-4d4c46896747'; $district=$geo->publicReferences()->where('parent_id',$province)->where('location_type','district')->first(); $editor=User::factory()->create();$reviewer=User::factory()->create();$template=$zones->visible()->firstOrFail();$ids=[]; foreach(['legal_scope','influence']as$scope){ $zone=$template->replicate();$zone->id=(string)Str::uuid();$zone->code='SYNTHETIC-'.Str::random(12);$zone->name='SYNTHETIC QA legal coverage';$zone->primary_territory_id='9e42dac8-fd9b-523f-bf59-71a7d3aa0fb8';$zone->save();$ids[$scope]=$zone->id; DB::table('investment_zone_locations')->insert(['id'=>(string)Str::uuid(),'zone_id'=>$zone->id,'geo_location_id'=>$scope==='legal_scope'?$province:$district->id,'scope_type'=>$scope,'source_reference'=>'SYNTHETIC isolated QA scope fixture','validation_status'=>'validated','editor_id'=>$editor->id,'reviewer_id'=>$reviewer->id,'valid_from'=>now()->subDay(),'version_no'=>1,'created_at'=>now(),'updated_at'=>now()]); } $matches=$zones->search(['province_id'=>$province,'district_id'=>$district->id])->pluck('id')->all(); $this->assertContains($ids['legal_scope'],$matches);$this->assertNotContains($ids['influence'],$matches); } }