Carteira 4.3: projectos integrados do PII como projectos planeados internos, por confirmar
Decisões do proprietário de 05/12: duplicados separados e referenciados, moeda do A10 indefinida, ANC fora do PII excluídos, registos internos e não publicados. O comando portfolio:load-pii-integrated simula por omissão e só cria com --execute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Services\PiiIntegratedProjects;
|
||||
use Database\Seeders\InvestmentPortfolioSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
final class PiiIntegratedProjectsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_integrated_projects_are_created_internal_planned_and_unconfirmed_without_inventing_values(): void
|
||||
{
|
||||
$this->seed(InvestmentPortfolioSeeder::class);
|
||||
$load = app(PiiIntegratedProjects::class);
|
||||
$before = DB::table('projects')->count();
|
||||
|
||||
$dry = $load->run(false);
|
||||
$this->assertCount(161, $dry['create']);
|
||||
$this->assertSame($before, DB::table('projects')->count());
|
||||
|
||||
$result = $load->run(true);
|
||||
$this->assertCount(161, $result['create']);
|
||||
$this->assertSame([], $result['collisions']);
|
||||
$created = DB::table('projects')->where('source_system', PiiIntegratedProjects::SOURCE_SYSTEM);
|
||||
$this->assertSame(161, (clone $created)->count());
|
||||
$this->assertSame(0, (clone $created)->where(fn ($q) => $q->where('status', '!=', 'planned')->orWhere('data_classification', '!=', 'internal'))->count());
|
||||
$this->assertSame(0, (clone $created)->whereNotNull('start_date')->count());
|
||||
$this->assertSame(0, DB::table('investment_dossiers')->whereIn('project_id', (clone $created)->select('id'))->count());
|
||||
$this->assertSame(0, DB::table('opportunities')->count());
|
||||
|
||||
// A10 table has a «USD/MZN» header: no currency is chosen, the literal is kept.
|
||||
$mphanda = (clone $created)->where('code', 'A10-C01')->first();
|
||||
$this->assertNull($mphanda->budget_amount);
|
||||
$this->assertSame('800.000.000', json_decode($mphanda->metadata, true)['pii']['cost_literal']);
|
||||
$this->assertSame('Cahora Bassa Norte (HCB)', $mphanda->name);
|
||||
|
||||
// Both container terminals stay, each pointing at the other.
|
||||
foreach (['A07-C02', 'A08-C02'] as $code) {
|
||||
$meta = json_decode((clone $created)->where('code', $code)->value('metadata'), true);
|
||||
$this->assertSame('por_confirmar', $meta['confirmation_status']);
|
||||
$this->assertCount(1, $meta['possible_duplicate_of']);
|
||||
$this->assertStringContainsString('Terminal de Contentores – Porto de Nacala', $meta['possible_duplicate_of'][0]);
|
||||
}
|
||||
$this->assertSame('16100000.00', (clone $created)->where('code', 'A03-C01')->value('budget_amount'));
|
||||
|
||||
$links = DB::table('complementary_project_links')->where('source_system', PiiIntegratedProjects::SOURCE_SYSTEM);
|
||||
$this->assertSame($result['links'], (clone $links)->count());
|
||||
$this->assertSame(161, $result['links'] + count($result['without_relation']));
|
||||
$this->assertSame(0, (clone $links)->where('data_classification', '!=', 'internal')->count());
|
||||
|
||||
$again = $load->run(true);
|
||||
$this->assertSame([[], 161], [$again['create'], $again['existing']]);
|
||||
$this->assertSame(161, (clone $created)->count());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user