This commit is contained in:
2026-11-23 10:40:48 +02:00
921 changed files with 182589 additions and 895 deletions
@@ -0,0 +1,36 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Services\VirtualDesk;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Tests\TestCase;
final class BusinessPlanDraftContinuityTest extends TestCase
{
use DatabaseTransactions;
public function test_incomplete_plans_keep_exact_values_in_their_own_dossier_after_a_new_session(): void
{
$identity = DB::selectOne('select current_database() as name, inet_server_port() as port');
$this->assertSame('continuity_20261120_test', $identity->name);
$this->assertSame(55441, (int) $identity->port);
config(['investor-path.enabled' => true]);
$owner = User::factory()->create();
$cases = [];
foreach (['Hotel sintético QA' => '250.50', 'Agronegócio sintético QA' => '375.25'] as $title => $price) {
$case = app(VirtualDesk::class)->createCase($owner, ['title' => $title, 'client_key' => (string) Str::uuid(), 'reuse_consent' => true]);
$snapshot = json_encode(['version' => 17, 'plan' => ['currency' => 'MZN', 'annualGrowthPercent' => '250', 'products' => [['label' => $title, 'monthlyUnits' => '25', 'unitPrice' => $price, 'unitVariableCost' => '100.50']], 'monthlyOperatingExpenses' => '500.25', 'salesCollectionPercent' => '', 'openingReceivablesCollectionPercent' => '']], JSON_THROW_ON_ERROR);
$this->actingAs($owner)->postJson('/api/v1/simulation-drafts', ['context' => $case->id, 'personal_snapshot' => [], 'economic_snapshot' => ['purpose' => 'simulate_only', 'journey_type' => 'small_business', 'business_plan_snapshot' => $snapshot]], ['Idempotency-Key' => (string) Str::uuid()])->assertCreated();
$cases[] = [$case->id, $snapshot];
}
$this->flushSession();
foreach ($cases as [$caseId, $snapshot]) {
$this->actingAs(User::findOrFail($owner->id))->getJson('/api/v1/simulation-drafts/current?context='.$caseId)->assertOk()->assertJsonPath('data.economic_snapshot.business_plan_snapshot', $snapshot);
}
$this->actingAs(User::factory()->create())->getJson('/api/v1/simulation-drafts/current?context='.$cases[0][0])->assertForbidden();
}
}
+48 -7
View File
@@ -2,16 +2,20 @@
namespace Tests\Feature;
use App\Models\Sector;
use App\Models\User;
use App\Services\DemographicEvidence;
use App\Services\DemographicImport;
use App\Services\InvestmentPreparationWorkspace;
use App\Services\Malware\MalwareScanner;
use App\Services\SectorContentAnalysis;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Tests\TestCase;
final class DemographyTest extends TestCase
@@ -77,6 +81,35 @@ final class DemographyTest extends TestCase
$this->assertSame([], app(DemographicEvidence::class)->analyse([$this->district], 2026, 2027)['territories']);
}
public function test_tourism_is_explicit_and_comparisons_include_intermediate_years(): void
{
$this->assertSame('Turismo', DemographicEvidence::sectors()['tourism']);
$response = $this->getJson('/api/v1/investment/demography?'.http_build_query(['territories' => [$this->district], 'start_year' => 2026, 'end_year' => 2028, 'sector' => 'tourism']))->assertOk();
$response->assertJsonPath('sector', 'tourism')->assertJsonPath('territories.0.series.0.values.0.original_value', '100.125');
$other = (array) DB::table('geo_locations')->where('id', $this->district)->first();
$other['id'] = (string) Str::uuid();
$other['code'] = $other['id'];
$other['external_id'] = '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:QA:'.$other['id'];
DB::table('geo_locations')->insert($other);
foreach (DB::table('demographic_observations')->where('geo_location_id', $this->district)->get() as $row) {
$row = (array) $row;
unset($row['id']);
DB::table('demographic_observations')->insert([...$row, 'geo_location_id' => $other['id']]);
}
$analysis = app(DemographicEvidence::class)->analyse([$this->district, $other['id']], 2026, 2028, 'commerce');
$this->assertSame([2026, 2027], array_column($analysis['comparisons'], 'year'));
$this->assertSame([], app(SectorContentAnalysis::class)->forTerritories([$this->district], 'commerce'));
}
public function test_commerce_and_territory_reach_the_normal_investor_entry(): void
{
$sector = Sector::firstOrCreate(['slug' => 'comercio-e-servicos'], ['name' => 'Comércio e serviços', 'is_active' => true]);
$this->get('/localizacoes/demografia?'.http_build_query(['territories' => [$this->district], 'sector' => 'commerce']))
->assertOk()->assertInertia(fn ($page) => $page->component('investment/demography')->where('entrySector', $sector->slug)->where('sectorReadings', []));
$this->actingAs(User::factory()->create())->get('/investimentos/iniciar?'.http_build_query(['source' => 'territory:'.$this->district, 'sector' => $sector->slug]))
->assertOk()->assertInertia(fn ($page) => $page->component('investor-path/context-start')->where('entryQuery.sector_id', (string) $sector->id)->where('source.id', $this->district)->etc());
}
public function test_new_editions_remain_separate_and_divergence_is_reported(): void
{
$other = $this->batch('approved');
@@ -202,8 +235,10 @@ final class DemographyTest extends TestCase
{
Storage::fake('local');
$disk = Storage::disk('local');
$original = 'SYNTHETIC prepared original'; $sha = hash('sha256', $original);
$directory = 'prepared/'.$sha; $disk->makeDirectory($directory);
$original = 'SYNTHETIC prepared original';
$sha = hash('sha256', $original);
$directory = 'prepared/'.$sha;
$disk->makeDirectory($directory);
$disk->put('synthetic.xlsx', $original);
$row = ['province' => 'SYNTHETIC province', 'territory' => 'SYNTHETIC province', 'level' => 'province',
'year' => 2026, 'indicator' => 'population', 'sex' => 'all', 'residence' => 'all', 'age_group' => 'all', 'unit' => 'pessoas',
@@ -214,10 +249,11 @@ final class DemographyTest extends TestCase
$preview = json_encode($report, JSON_THROW_ON_ERROR);
$receipt = ['sha256' => $sha, 'baseline_year' => null, 'parser_sha256' => hash_file('sha256', base_path('tools/demography_workbook.py')),
'preview_sha256' => hash('sha256', $preview), 'records_sha256' => hash('sha256', $records), 'record_count' => 1];
$disk->put($directory.'/preview.json', $preview); $disk->put($directory.'/records.ndjson', $records);
$disk->put($directory.'/preview.json', $preview);
$disk->put($directory.'/records.ndjson', $records);
$disk->put($directory.'/preparation.json', json_encode($receipt, JSON_THROW_ON_ERROR));
config(['demography.prepared_directory' => $disk->path('prepared'), 'demography.python' => '/missing-python-must-not-run']);
$this->mock(\App\Services\Malware\MalwareScanner::class)->shouldReceive('scan')->once()->andReturn([
$this->mock(MalwareScanner::class)->shouldReceive('scan')->once()->andReturn([
'result' => 'clean', 'engine' => 'synthetic', 'engine_version' => 'test']);
$service = app(DemographicImport::class);
$this->assertTrue($service->preparedSourcesReady(['synthetic.xlsx' => ['sha256' => $sha, 'records' => 1]]));
@@ -227,9 +263,14 @@ final class DemographyTest extends TestCase
$this->assertSame('100.125', DB::table('demographic_observations')->where('import_id', $result['id'])->value('numeric_value'));
$this->assertSame('imported', DB::table('demographic_imports')->where('id', $result['id'])->value('status'));
$disk->put($directory.'/records.ndjson', 'TAMPERED');
try { $service->preparedSource($sha, null); $this->fail('Changed prepared records must be refused.'); }
catch (\Symfony\Component\HttpKernel\Exception\HttpException $error) { $this->assertSame(409, $error->getStatusCode()); }
$receipt['parser_sha256'] = str_repeat('0', 64); $disk->put($directory.'/preparation.json', json_encode($receipt, JSON_THROW_ON_ERROR));
try {
$service->preparedSource($sha, null);
$this->fail('Changed prepared records must be refused.');
} catch (HttpException $error) {
$this->assertSame(409, $error->getStatusCode());
}
$receipt['parser_sha256'] = str_repeat('0', 64);
$disk->put($directory.'/preparation.json', json_encode($receipt, JSON_THROW_ON_ERROR));
$this->assertFalse($service->preparedSourcesReady(['synthetic.xlsx' => ['sha256' => $sha, 'records' => 1]]));
}
+29 -10
View File
@@ -14,21 +14,31 @@ use Tests\TestCase;
final class FundingCriteriaCoherenceTest extends TestCase
{
use DatabaseTransactions;
private User $editor;
private array $geo = [];
private int $sector;
protected function setUp(): void
{
parent::setUp(); $this->withoutVite();
parent::setUp();
$this->withoutVite();
$db = DB::selectOne('select current_database() as name, inet_server_port() as port');
$this->assertSame('investor_intent_20261115_test', $db->name); $this->assertSame(55441, (int) $db->port);
$this->editor = User::factory()->create(); config(['portal.managers' => [$this->editor->email]]);
$this->assertContains($db->name, ['investor_intent_20261115_test', 'continuity_20261120_test']);
$this->assertSame(55441, (int) $db->port);
// Counts below concern this test's fixtures. Existing browser fixtures
// remain unchanged after DatabaseTransactions rolls the test back.
DB::table('funding_programmes')->update(['published_version_id' => null]);
$this->editor = User::factory()->create();
config(['portal.managers' => [$this->editor->email]]);
$parent = null;
foreach (['country', 'province', 'district'] as $type) {
$id = (string) Str::uuid();
DB::table('geo_locations')->insert(['id' => $id, 'parent_id' => $parent, 'name' => 'SYNTHETIC '.$type, 'code' => $id, 'location_type' => $type, 'source_system' => 'cartografia-workbook', 'data_classification' => 'public', 'external_id' => '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:QA:'.$id]);
$this->geo[$type] = $id; $parent = $id;
$this->geo[$type] = $id;
$parent = $id;
}
$this->sector = Sector::create(['slug' => 'synthetic-funding-qa', 'name' => 'SYNTHETIC sector', 'is_active' => true, 'published_at' => now()])->id;
}
@@ -37,13 +47,16 @@ final class FundingCriteriaCoherenceTest extends TestCase
{
$source = ['source_url' => 'https://example.invalid/synthetic-qa', 'source_reference' => 'SYNTHETIC QA ONLY', 'checked_on' => today()->toDateString()];
$draft = ['title' => 'SYNTHETIC '.$code, 'kind' => $kind, 'manager_name' => 'SYNTHETIC manager', 'summary' => 'Synthetic isolated record, not real content.', 'source_url' => $source['source_url'], 'source_reference' => $source['source_reference'], 'source_checked_on' => $source['checked_on'], 'source_status' => 'identified', 'coverage' => 'national', 'sectors_scope' => 'all', 'funding_needs' => ['investment'], 'windows' => []];
if ($kind === 'institution') $draft += ['institution_key' => $code, 'institution_nature' => 'bank', 'institution_categories' => ['banking'], 'institution_types' => ['commercial_bank'], 'institution_status' => 'reported',
'locations' => [['role' => 'headquarters', 'label' => 'Synthetic headquarters', 'territory_id' => $this->geo['district'], 'evidence_status' => 'reported', ...$source]],
'products' => [['code' => 'investment', 'title' => 'Synthetic investment product', 'needs' => ['investment'], 'coverage' => 'national', 'availability' => 'documented', ...$source]]];
if ($kind === 'institution') {
$draft += ['institution_key' => $code, 'institution_nature' => 'bank', 'institution_categories' => ['banking'], 'institution_types' => ['commercial_bank'], 'institution_status' => 'reported',
'locations' => [['role' => 'headquarters', 'label' => 'Synthetic headquarters', 'territory_id' => $this->geo['district'], 'evidence_status' => 'reported', ...$source]],
'products' => [['code' => 'investment', 'title' => 'Synthetic investment product', 'needs' => ['investment'], 'coverage' => 'national', 'availability' => 'documented', ...$source]]];
}
$service = app(FundingProgrammes::class);
$id = $service->save($this->editor, null, ['version' => 0, 'code' => $code, 'reason' => 'Synthetic QA fixture', 'draft' => array_replace($draft, $overrides)]);
$plan = $service->preview($this->editor, $id);
$service->publish($this->editor, $id, ['version' => $plan['version'], 'hash' => $plan['hash'], 'confirm' => true, 'reason' => 'Synthetic QA only, rolled back']);
return $id;
}
@@ -62,7 +75,9 @@ final class FundingCriteriaCoherenceTest extends TestCase
$this->get('/fundos?'.http_build_query($filters))->assertOk()->assertInertia(fn ($page) => $page->has('items.data', 1)->where('items.data.0.id', $bank)->where('territorySelection.0.id', $this->geo['province'])->where('territorySelection.1.id', $this->geo['district']));
$returnFilters = [...$filters, 'q' => 'qa', 'state' => 'closed', 'kind' => 'institution', 'include_historical' => '0', 'province_id' => $this->geo['province'], 'district_id' => $this->geo['district'], 'page' => '2'];
$this->get('/fundos/'.$bank.'?'.http_build_query($returnFilters))->assertOk()->assertInertia(function ($page) use ($returnFilters) {
foreach ($returnFilters as $key => $value) $page->where('selection.'.$key, (string) $value);
foreach ($returnFilters as $key => $value) {
$page->where('selection.'.$key, (string) $value);
}
});
$this->getJson('/api/v1/investment/territory-options?type=district')->assertOk()->assertJsonCount(0, 'data');
$this->getJson('/api/v1/investment/territory-options?type=district&parent_id='.$this->geo['province'])->assertOk()->assertJsonCount(1, 'data');
@@ -82,8 +97,12 @@ final class FundingCriteriaCoherenceTest extends TestCase
public function test_contradictory_type_or_record_kind_and_incomplete_hierarchy_are_rejected(): void
{
foreach ([['category' => 'banking', 'institution_type' => 'broker'], ['category' => 'banking', 'institution_type' => 'commercial_bank', 'kind' => 'fund', 'location_mode' => 'physical'], ['district_id' => $this->geo['district']]] as $filters) {
try { app(FundingProgrammes::class)->catalogueQuery($filters)->count(); $this->fail('Contradictory criteria must not silently broaden a query.'); }
catch (ValidationException $error) { $this->assertNotEmpty($error->errors()); }
try {
app(FundingProgrammes::class)->catalogueQuery($filters)->count();
$this->fail('Contradictory criteria must not silently broaden a query.');
} catch (ValidationException $error) {
$this->assertNotEmpty($error->errors());
}
$this->getJson('/fundos?'.http_build_query($filters))->assertUnprocessable();
$this->get('/fundos?'.http_build_query($filters))->assertOk()->assertInertia(fn ($page) => $page->has('criteriaErrors')->has('items.data', 0));
}
@@ -0,0 +1,59 @@
<?php
namespace Tests\Feature;
use App\Services\FundingProgrammes;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
/** Uses unchanged documentary institutions in the explicitly guarded QA fixture. */
final class FundingLocalPresenceAcceptanceTest extends TestCase
{
use DatabaseTransactions;
private array $fixture;
protected function setUp(): void
{
parent::setUp();
$this->withoutVite();
$this->assertSame('continuity_20261120_test', DB::connection()->getDatabaseName());
$this->fixture = json_decode(file_get_contents(base_path('outputs/funding-b03-b06-20261120/fixture.json')), true, 512, JSON_THROW_ON_ERROR);
$this->assertSame($this->fixture['source_sha256'], hash_file('sha256', database_path('data/funding-institutions-nov2026.json')));
}
private function ids(string $province, string $mode, string $certainty = 'include_unknown'): array
{
return app(FundingProgrammes::class)->catalogueQuery(['territory' => $this->fixture['provinces'][$province], 'location_mode' => $mode, 'kind' => 'institution', 'need' => 'investment', 'certainty' => $certainty])->pluck('p.id')->all();
}
public function test_national_financing_is_not_a_physical_branch_and_unknowns_are_not_confirmed(): void
{
$moza = $this->fixture['records']['moza']['id'];
$microbank = $this->fixture['records']['ac-microbanco']['id'];
$this->assertContains($moza, $this->ids('Niassa', 'coverage'));
$this->assertNotContains($moza, $this->ids('Niassa', 'physical'));
$this->assertContains($moza, $this->ids('Maputo Cidade', 'physical'));
$this->assertContains($this->fixture['records']['bci']['id'], $this->ids('Maputo Cidade', 'physical', 'documented'));
$this->assertNotContains($microbank, $this->ids('Gaza', 'physical', 'documented'));
$this->assertContains($microbank, $this->ids('Gaza', 'physical'));
}
public function test_empty_local_result_does_not_fall_back_to_the_national_catalogue(): void
{
$district = DB::table('geo_locations')->where('parent_id', $this->fixture['provinces']['Niassa'])->where('location_type', 'district')->firstOrFail();
$filters = ['territory' => $district->id, 'kind' => 'institution', 'need' => 'investment', 'location_mode' => 'physical', 'certainty' => 'documented'];
$this->get('/fundos?'.http_build_query($filters))->assertOk()
->assertInertia(fn ($page) => $page->component('funding/index')->has('items.data', 0)->where('filters.territory', $district->id)->where('filters.location_mode', 'physical')->etc());
}
public function test_each_documentary_institution_selection_opens_its_own_record(): void
{
foreach ($this->fixture['records'] as $key => $record) {
$this->get('/fundos/'.$record['id'].'?'.http_build_query(['location_mode' => 'physical', 'territory' => $this->fixture['provinces']['Maputo Cidade'], 'need' => 'investment']))->assertOk()
->assertInertia(fn ($page) => $page->component('funding/show')->where('record.id', $record['id'])->where('record.payload.title', $record['title'])->where('record.payload.institution_key', $key)->where('selection.location_mode', 'physical')->etc());
}
$this->get('/fundos/00000000-0000-4000-8000-000000000000')->assertNotFound();
}
}
@@ -0,0 +1,55 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use App\Services\VirtualDesk;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
use Tests\TestCase;
class InvestorIntegralReportTest extends TestCase
{
use DatabaseTransactions;
public function test_private_report_snapshots_are_preserved_in_the_exact_result_version_without_exposing_them_in_events(): void
{
$identity = DB::selectOne('select current_database() as name, inet_server_port() as port');
$this->assertStringEndsWith('_test', $identity->name);
$this->assertSame(55441, (int) $identity->port);
$this->withoutVite();
Http::fake();
$owner = User::factory()->create();
config(['investor-path.enabled' => true, 'portal.managers' => [$owner->email], 'suitecrm.enabled' => false, 'investmoz_ai.enabled' => false]);
$this->actingAs($owner);
if (! DB::table('desk_service_versions')->where('code', 'project-preparation')->exists()) {
$this->postJson('/management/balcao/servicos', ['code' => 'project-preparation', 'confirm' => true])->assertCreated();
}
$case = $this->postJson('/investimentos', ['title' => 'QA synthetic report transport', 'client_key' => (string) Str::uuid(), 'reuse_consent' => true])->assertCreated()->json('id');
// Transport contract only: no invented financial amounts or calculated results.
$economic = [
'purpose' => 'simulate_only',
'financial_tools_snapshot' => json_encode(['version' => 1, 'data' => []], JSON_THROW_ON_ERROR),
'business_plan_snapshot' => json_encode(['version' => 17, 'plan' => ['fixture' => 'synthetic transport only']], JSON_THROW_ON_ERROR),
'project_team_snapshot' => json_encode([['competency' => 'QA role', 'state' => 'unknown', 'action' => '', 'estimated_cost' => '', 'due_date' => '']], JSON_THROW_ON_ERROR),
'project_execution_snapshot' => json_encode([['title' => 'QA milestone', 'due_date' => '', 'status' => 'planned', 'planned_amount' => '', 'actual_amount' => '']], JSON_THROW_ON_ERROR),
];
$draft = $this->postJson('/api/v1/simulation-drafts', ['context' => $case, 'personal_snapshot' => [], 'economic_snapshot' => $economic], ['Idempotency-Key' => (string) Str::uuid()])->assertCreated()->json('data.id');
$view = $this->getJson('/investimentos/'.$case)->assertOk()->json();
$request = ['version' => $view['case']['version'], 'draft_id' => $draft, 'draft_version' => 1];
$result = $this->postJson('/investimentos/'.$case.'/resultados', $request)->assertOk()->json('result');
foreach (['business_plan_snapshot', 'project_team_snapshot', 'project_execution_snapshot'] as $field) {
$this->assertSame($economic[$field], $result['preparation_snapshot'][$field]);
}
$this->postJson('/investimentos/'.$case.'/resultados', $request)->assertOk()->assertJsonPath('result.id', $result['id']);
$this->flushSession();
$this->actingAs($owner)->getJson('/investimentos/'.$case)->assertOk()->assertJsonPath('results.0.preparation_snapshot', $result['preparation_snapshot']);
$event = app(VirtualDesk::class)->decode(DB::table('desk_events')->where('case_id', $case)->where('action', 'tool_evidence_returned')->value('payload'));
foreach (['business_plan_snapshot', 'project_team_snapshot', 'project_execution_snapshot'] as $field) {
$this->assertArrayNotHasKey($field, $event['preparation_snapshot']);
}
$this->actingAs(User::factory()->create())->getJson('/investimentos/'.$case)->assertForbidden();
}
}
@@ -0,0 +1,71 @@
<?php
namespace Tests\Feature;
use App\Http\Controllers\InvestmentPortfolioController;
use App\Models\Opportunity;
use App\Models\User;
use App\Services\CorridorAgribusinessOpportunities;
use App\Services\InvestmentCatalogue;
use App\Services\InvestmentGeography;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
/** Existing documentary records and disclosure states only; never creates opportunities. */
final class PortfolioOpportunityAcceptanceTest extends TestCase
{
use DatabaseTransactions;
protected function setUp(): void
{
parent::setUp();
$this->withoutVite();
$this->assertSame('main_reference_20261104_test', DB::connection()->getDatabaseName());
}
public function test_documentary_source_records_are_available_and_searchable_without_inventing_sites(): void
{
$entries = app(CorridorAgribusinessOpportunities::class)->entries();
$this->assertCount(34, $entries);
foreach ($entries as $entry) {
$record = Opportunity::where('management_creation_key', $entry['key'])->firstOrFail();
$this->assertTrue(Opportunity::published()->whereKey($record->id)->exists(), $entry['title']);
$this->assertTrue(app(InvestmentCatalogue::class)->query(['q' => $entry['chain']])->whereKey($record->id)->exists(), $entry['title']);
$this->assertNull($record->primary_territory_id);
$this->assertNull($record->province);
}
}
public function test_public_opportunities_are_embedded_even_without_matching_portfolio_fiches(): void
{
$record = Opportunity::published()->where('title', 'Soja — Corredor da Beira')->firstOrFail();
$this->get('/carteira?q=Soja')->assertOk()->assertInertia(fn ($page) => $page->component('portfolio/index')
->has('publishedOpportunities.data', 2)
->where('publishedOpportunities.data', fn ($items) => collect($items)->contains('id', $record->id))->etc());
$this->get('/carteira?kind=corridor&q=Beira')->assertOk()->assertInertia(fn ($page) => $page->component('portfolio/index')->has('publishedOpportunities.data', 7)->etc());
}
public function test_province_does_not_promote_unsited_opportunities_or_fiches_from_another_province(): void
{
$geography = app(InvestmentGeography::class);
$zambezia = $geography->publicReferences()->where('location_type', 'province')->where('name', 'Zambezia')->value('id');
$maputo = $geography->publicReferences()->where('location_type', 'province')->where('name', 'Maputo Província')->value('id');
$mocuba = InvestmentPortfolioController::visible()->where('title', 'Construção da Cidadela Parlamentar de Mocuba')->firstOrFail();
foreach ([[$zambezia, true], [$maputo, false]] as [$province, $expected]) {
$this->assertNotEmpty($province);
$this->get('/carteira?'.http_build_query(['province_id' => $province, 'q' => 'Mocuba']))->assertOk()->assertInertia(fn ($page) => $page->component('portfolio/index')
->where('records.data', fn ($items) => collect($items)->contains('id', $mocuba->id) === $expected)->etc());
$this->get('/carteira?'.http_build_query(['province_id' => $province, 'q' => 'Soja']))->assertOk()->assertInertia(fn ($page) => $page->component('portfolio/index')->has('publishedOpportunities.data', 0)->etc());
}
}
public function test_real_published_opportunity_reaches_normal_private_entry_without_invented_territory(): void
{
$record = Opportunity::published()->where('title', 'Soja — Corredor da Beira')->firstOrFail();
$actor = User::factory()->create(['name' => 'SINTÉTICO — verificação de percurso documental']);
$this->actingAs($actor)->get('/investimentos/iniciar?source=opportunity:'.$record->id)->assertOk()
->assertInertia(fn ($page) => $page->component('investor-path/context-start')->where('source.id', (string) $record->id)->etc());
$this->assertNull($record->fresh()->primary_territory_id);
}
}
+1 -1
View File
@@ -131,7 +131,7 @@ final class SectorContentAnalysisTest extends TestCase
'location_type' => $type, 'source_system' => 'cartografia-workbook', 'data_classification' => 'public',
'external_id' => '964a187ad32ea553b9e112cd159caa90b900050c42b7329594a75bcd798a96ff:QA:'.$id]);
}
$readings = app(SectorContentAnalysis::class)->forTerritories([$district]);
$readings = app(SectorContentAnalysis::class)->forTerritories([$district], 'tourism');
$this->assertCount(1, $readings);
$this->assertSame($article['href'], $readings[0]['href']);
$this->assertSame('Maputo Província', $readings[0]['analysis']['region']);