insertOrIgnore(['id' => 12, 'nome' => 'Admin Test', 'cognome' => 'Test', 'created_at' => now(), 'updated_at' => now()]); $stabile = Stabile::where('codice_stabile', '0021')->first(); if (! $stabile) { $mirrorCount = DB::connection('gescon_import') ->table('condomin_mirror') ->where('cod_stabile', '0021') ->count(); if ($mirrorCount === 0) { Artisan::call('gescon:import-mirror-0021'); } Artisan::call('gescon:reconstruct-mirror-0021'); } }); test('gescon:sync-anagrafica-consolidata materializes persons and promotes fornitori including Nethome 246', function () { Artisan::call('gescon:sync-anagrafica-consolidata', ['amministratore_id' => 12]); $rubricaCount = RubricaUniversale::where('amministratore_id', 12)->count(); expect($rubricaCount)->toBeGreaterThan(300); $fornitoriCount = Fornitore::where('amministratore_id', 12)->count(); expect($fornitoriCount)->toBeGreaterThan(0); $nethome = Fornitore::where('amministratore_id', 12) ->where(function ($q) { $q->where('old_id', 246)->orWhere('cod_forn', 246)->orWhere('partita_iva', '10055221005'); })->first(); expect($nethome)->not->toBeNull(); expect($nethome->ragione_sociale)->toContain('NETHOME'); expect($nethome->partita_iva)->toBe('10055221005'); $stabiliTotal = Stabile::count(); expect($stabiliTotal)->toBeGreaterThan(0); $stabile0021 = Stabile::where('codice_stabile', '0021')->first(); expect($stabile0021)->not->toBeNull(); $unitsCount = UnitaImmobiliare::where('stabile_id', $stabile0021->id)->count(); expect($unitsCount)->toBe(230); $unitA11 = UnitaImmobiliare::where('stabile_id', $stabile0021->id)->where('scala', 'A')->where('interno', '11')->first(); expect($unitA11)->not->toBeNull(); $rels = DB::table('persone_unita_relazioni')->where('unita_id', $unitA11->id)->get(); expect($rels->count())->toBeGreaterThanOrEqual(2); $aterRel = $rels->firstWhere('attivo', 0); expect($aterRel)->not->toBeNull(); $benedettoRel = $rels->firstWhere('attivo', 1); expect($benedettoRel)->not->toBeNull(); });