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()); } }