This commit is contained in:
@@ -149,6 +149,40 @@ class InvestmentTerritoryTest extends TestCase
|
||||
$this->assertNotContains($national->id, $service->query([])->pluck('id')->all());
|
||||
}
|
||||
|
||||
public function test_opportunity_cluster_and_corridor_filters_use_their_public_opportunity_relations(): void
|
||||
{
|
||||
$country = $this->location('country');
|
||||
$province = $this->location('province', $country);
|
||||
$otherProvince = $this->location('province', $country);
|
||||
foreach ([$country, $province, $otherProvince] as $territoryId) {
|
||||
DB::table('geo_locations')->where('id', $territoryId)->update(['source_system' => 'cartografia-workbook',
|
||||
'external_id' => '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:'.$territoryId,
|
||||
'data_classification' => 'public']);
|
||||
}
|
||||
$sector = Sector::create(['name' => 'Public relation test', 'slug' => 'public-relation-test', 'is_active' => true]);
|
||||
$corridorId = (string) Str::uuid();
|
||||
DB::table('development_corridors')->insert(['id' => $corridorId, 'code' => 'QA-CORRIDOR', 'name' => 'QA public corridor',
|
||||
'status' => 'active', 'data_classification' => 'public', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$clusterId = (string) Str::uuid();
|
||||
DB::table('economic_clusters')->insert(['id' => $clusterId, 'code' => 'QA-CLUSTER', 'name' => 'QA public cluster',
|
||||
'sector' => 'QA', 'status' => 'active', 'data_classification' => 'public', 'created_at' => now(), 'updated_at' => now()]);
|
||||
$opportunity = Opportunity::create(['sector_id' => $sector->id, 'reference' => 'QA-CORRIDOR-OPP', 'slug' => 'qa-corridor-opp',
|
||||
'title' => 'QA opportunity linked to corridor', 'status' => 'published', 'published_at' => now()->subMinute(), 'primary_territory_id' => $province]);
|
||||
DB::table('opportunity_corridors')->insert(['opportunity_id' => $opportunity->id, 'corridor_id' => $corridorId]);
|
||||
DB::table('opportunity_clusters')->insert(['opportunity_id' => $opportunity->id, 'cluster_id' => $clusterId]);
|
||||
|
||||
$this->getJson('/api/v1/investment/references')->assertOk()->assertJsonFragment(['id' => $corridorId, 'name' => 'QA public corridor'])
|
||||
->assertJsonFragment(['id' => $clusterId, 'name' => 'QA public cluster']);
|
||||
$this->getJson('/api/v1/investment/search?dimension=corridor&province_id='.$province)->assertOk()
|
||||
->assertJsonPath('total', 1)->assertJsonPath('data.0.id', $opportunity->id);
|
||||
$this->getJson('/api/v1/investment/search?corridor_id='.$corridorId.'&province_id='.$province)->assertOk()
|
||||
->assertJsonPath('total', 1)->assertJsonPath('data.0.id', $opportunity->id);
|
||||
$this->getJson('/api/v1/investment/search?cluster_id='.$clusterId)->assertOk()
|
||||
->assertJsonPath('total', 1)->assertJsonPath('data.0.id', $opportunity->id);
|
||||
$this->getJson('/api/v1/investment/search?dimension=corridor&province_id='.$otherProvince)->assertOk()
|
||||
->assertJsonPath('total', 0)->assertJsonCount(0, 'data');
|
||||
}
|
||||
|
||||
public function test_cluster_territory_uses_only_public_validated_project_links_and_project_locations(): void
|
||||
{
|
||||
$country = $this->location('country');
|
||||
|
||||
Reference in New Issue
Block a user