This commit is contained in:
@@ -44,7 +44,7 @@ class InvestmentZoneTest extends TestCase
|
||||
$this->getJson('/api/v2/investment/zones')->assertJsonPath('records.total', 0);
|
||||
$this->postJson($url.'/'.$id, [...$payload, '_method' => 'PUT', 'version_no' => 1, 'name' => 'Changed synthetic zone'])->assertOk()->assertJsonPath('version_no', 2);
|
||||
$this->putJson($url.'/'.$id, [...$payload, 'version_no' => 1])->assertConflict();
|
||||
$this->postJson($url.'/'.$id.'/publish', ['version_no' => 2])->assertForbidden();
|
||||
$this->postJson($url.'/'.$id.'/publish', ['version_no' => 2])->assertUnprocessable();
|
||||
$this->actingAs($this->manager())->postJson($url.'/'.$id.'/publish', ['version_no' => 2])->assertUnprocessable();
|
||||
$this->assertDatabaseCount('investment_zone_revisions', 2);
|
||||
$snapshot = DB::table('investment_zone_revisions')->where('zone_id', $id)->where('version_no', 1)->value('snapshot');
|
||||
@@ -123,8 +123,7 @@ class InvestmentZoneTest extends TestCase
|
||||
public function test_documented_general_industrial_park_can_publish_without_special_regime_or_operator_and_filters_match_csv(): void
|
||||
{
|
||||
$editor = $this->manager();
|
||||
$publisher = $this->manager();
|
||||
config(['investment-zones.publishers' => [$publisher->email]]);
|
||||
config(['investment-zones.publishers' => []]);
|
||||
$country = $this->geoNode('country', 'Synthetic country for park', null);
|
||||
$province = $this->geoNode('province', 'Synthetic province for park', $country);
|
||||
$evidence = [['title' => 'Synthetic municipal project page', 'url' => 'https://example.test/munhava', 'source_type' => 'institutional',
|
||||
@@ -136,7 +135,7 @@ class InvestmentZoneTest extends TestCase
|
||||
'source_evidence' => $evidence, 'area_components' => [['type' => 'pilot', 'value' => 50, 'unit' => 'ha', 'status' => 'reported',
|
||||
'source_reference' => 'Synthetic source reports pilot area; not available land.', 'source_date' => null]],
|
||||
])->assertCreated()->json('id');
|
||||
$this->actingAs($publisher)->postJson('/api/v2/investment/admin/zones/'.$id.'/publish', ['version_no' => 1])->assertOk();
|
||||
$this->actingAs($editor)->postJson('/api/v2/investment/admin/zones/'.$id.'/publish', ['version_no' => 1])->assertOk();
|
||||
$this->getJson('/api/v2/investment/zones?development_status=planned')->assertOk()->assertJsonPath('records.total', 1)
|
||||
->assertJsonPath('records.data.0.id', $id)->assertJsonPath('records.data.0.availability_status', 'not_informed');
|
||||
$csv = $this->get('/api/v2/investment/zones/export.csv?development_status=planned')->assertOk()->assertHeader('content-type', 'text/csv; charset=UTF-8');
|
||||
@@ -148,6 +147,55 @@ class InvestmentZoneTest extends TestCase
|
||||
$this->assertDatabaseHas('investment_zones', ['id' => $id, 'operator_id' => null, 'legal_source_id' => null, 'publication_status' => 'published']);
|
||||
}
|
||||
|
||||
public function test_promoter_sourced_industrial_park_can_be_published_as_informational_only(): void
|
||||
{
|
||||
$manager = $this->manager();
|
||||
config(['investment-zones.publishers' => []]);
|
||||
$country = $this->geoNode('country', 'Synthetic country for promoter park', null);
|
||||
$province = $this->geoNode('province', 'Synthetic province for promoter park', $country);
|
||||
$id = $this->actingAs($manager)->postJson('/api/v2/investment/admin/zones', [
|
||||
'code' => 'QA-PROMOTER-PARK', 'name' => 'Synthetic promoter-sourced park', 'category' => 'industrial_park',
|
||||
'physical_category' => 'industrial_park', 'legal_regime' => 'pending', 'development_status' => 'in_development',
|
||||
'availability_status' => 'not_informed',
|
||||
'description' => 'Informational project record; legal status, operations, incentives and available land are not confirmed.',
|
||||
'province_id' => $province,
|
||||
'source_evidence' => [['title' => 'Promoter project page', 'url' => 'https://example.test/promoter-park', 'source_type' => 'promoter',
|
||||
'supports' => 'The promoter identifies the project and province; no legal designation or land availability claim.', 'source_date' => null]],
|
||||
])->assertCreated()->json('id');
|
||||
|
||||
$this->postJson('/api/v2/investment/admin/zones/'.$id.'/publish', ['version_no' => 1])->assertOk();
|
||||
$this->getJson('/api/v2/investment/zones?category=industrial_park')->assertOk()
|
||||
->assertJsonPath('records.total', 1)->assertJsonPath('records.data.0.id', $id)
|
||||
->assertJsonPath('records.data.0.legal_regime', 'pending')
|
||||
->assertJsonPath('records.data.0.availability_status', 'not_informed')
|
||||
->assertJsonPath('records.data.0.source_evidence.0.source_type', 'promoter');
|
||||
$this->assertDatabaseHas('investment_zones', ['id' => $id, 'publication_status' => 'published', 'legal_regime' => 'pending',
|
||||
'operator_id' => null, 'legal_source_id' => null]);
|
||||
}
|
||||
|
||||
public function test_officially_sourced_zee_can_be_published_informationally_by_the_authenticated_author(): void
|
||||
{
|
||||
$manager = $this->manager();
|
||||
config(['investment-zones.publishers' => []]);
|
||||
$country = $this->geoNode('country', 'Synthetic country for ZEE', null);
|
||||
$province = $this->geoNode('province', 'Synthetic province for ZEE', $country);
|
||||
$id = $this->actingAs($manager)->postJson('/api/v2/investment/admin/zones', [
|
||||
'code' => 'QA-INFO-ZEE', 'name' => 'Synthetic reported ZEE', 'category' => 'zee',
|
||||
'physical_category' => 'economic_zone', 'legal_regime' => 'zee',
|
||||
'description' => 'Informational record; legal status and incentives remain unconfirmed.', 'province_id' => $province,
|
||||
'source_evidence' => [['title' => 'Institutional source', 'url' => 'https://example.test/zee', 'source_type' => 'institutional',
|
||||
'supports' => 'Reports the zone identity and province; does not confirm current legal status or incentives.', 'source_date' => null]],
|
||||
])->assertCreated()->json('id');
|
||||
|
||||
$this->postJson('/api/v2/investment/admin/zones/'.$id.'/publish', ['version_no' => 1])->assertOk();
|
||||
$this->getJson('/api/v2/investment/zones?category=zee')->assertOk()->assertJsonPath('records.total', 1)
|
||||
->assertJsonPath('records.data.0.id', $id);
|
||||
$this->get('/oportunidades?province_id='.$province)->assertOk()
|
||||
->assertInertia(fn ($page) => $page->has('references.zones', 1)->where('references.zones.0.id', $id));
|
||||
$this->assertDatabaseHas('investment_zones', ['id' => $id, 'editor_id' => $manager->id, 'reviewer_id' => $manager->id,
|
||||
'publication_status' => 'published', 'operator_id' => null, 'legal_source_id' => null]);
|
||||
}
|
||||
|
||||
public function test_zone_record_separates_physical_type_and_legal_regime_and_searches_multiple_reviewed_territories_once(): void
|
||||
{
|
||||
$editor = $this->manager();
|
||||
@@ -280,9 +328,11 @@ class InvestmentZoneTest extends TestCase
|
||||
$organization = (string) Str::uuid();
|
||||
DB::table('organizations')->insert(['id' => $organization, 'name' => 'Synthetic operator', 'organization_type' => 'private']);
|
||||
$sector = Sector::create(['slug' => 'qa-zone-sector', 'name' => 'Synthetic sector', 'is_active' => true]);
|
||||
$opportunity = Opportunity::create(['sector_id' => $sector->id, 'reference' => 'QA-ZONE', 'slug' => 'qa-zone', 'title' => 'Synthetic investment', 'status' => 'published', 'published_at' => now()->subMinute()]);
|
||||
$zoneCountry = $this->geoNode('country', 'Synthetic Country for zone link', null);
|
||||
$zoneProvince = $this->geoNode('province', 'Synthetic Province for zone link', $zoneCountry);
|
||||
$opportunity = Opportunity::create(['sector_id' => $sector->id, 'reference' => 'QA-ZONE', 'slug' => 'qa-zone', 'title' => 'Synthetic investment',
|
||||
'status' => 'published', 'published_at' => now()->subMinute(), 'province' => 'Synthetic Province for zone link',
|
||||
'geography_scope' => 'specific', 'primary_territory_id' => $zoneProvince]);
|
||||
$zoneIds = [];
|
||||
foreach (['zee', 'zfi'] as $category) {
|
||||
$this->actingAs($editor);
|
||||
@@ -313,6 +363,11 @@ class InvestmentZoneTest extends TestCase
|
||||
$this->getJson('/api/v1/investment/search?dimension=zfi&view=list')->assertOk()->assertJsonPath('total', 1);
|
||||
$this->getJson('/api/v1/investment/search?dimension=zee&q=not-present')->assertJsonPath('total', 0);
|
||||
$this->getJson('/api/v1/investment/search?dimension=invalid')->assertUnprocessable();
|
||||
$this->get('/oportunidades?province_id='.$zoneProvince.'&zee_id='.$zoneIds['zee_id'])->assertOk()
|
||||
->assertInertia(fn ($page) => $page->component('investment/catalogue')->has('references.zones', 2)
|
||||
->has('results.data', 1)->where('results.data.0.id', $opportunity->id));
|
||||
$this->getJson('/api/v2/investment/zones/'.$zoneIds['zee_id'])->assertOk()
|
||||
->assertJsonPath('opportunities.total', 1)->assertJsonPath('opportunities.data.0.id', $opportunity->id);
|
||||
$this->getJson('/api/v2/investment/zones')->assertJsonPath('records.total', 2)->assertJsonMissingPath('records.data.0.editor_id');
|
||||
$this->getJson('/api/v2/investment/zone-map')->assertJsonCount(2, 'features');
|
||||
$this->seed(InvestmentReferenceSeeder::class);
|
||||
@@ -382,7 +437,8 @@ class InvestmentZoneTest extends TestCase
|
||||
$this->assertDatabaseCount('investment_zone_relations', 3);
|
||||
$this->assertDatabaseCount('investment_items', 0);
|
||||
config(['investment-zones.publishers' => [], 'investment-zones.legal_reviewers' => [], 'investment-zones.gis_reviewers' => []]);
|
||||
$this->postJson('/api/v2/investment/admin/zones/'.$id.'/publish', ['version_no' => 1])->assertForbidden();
|
||||
$this->postJson('/api/v2/investment/admin/zones/'.$id.'/publish', ['version_no' => 1])->assertUnprocessable();
|
||||
$this->assertDatabaseHas('investment_zones', ['id' => $id, 'publication_status' => 'draft']);
|
||||
$this->getJson('/api/v2/investment/zones')->assertJsonPath('records.total', 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user