withoutVite(); $this->seed(RolesAndPermissionsSeeder::class); Setting::firstOrCreate([], ['congregazione_nome' => 'Congregazione di prova']); $this->admin = User::create(['name' => 'Admin', 'email' => 'admin@example.test', 'password' => 'password-di-prova']); $this->admin->assignRole('amministratore'); $this->territorio = Territorio::create(['numero' => '7', 'attivo' => true]); $this->proclamatore = Proclamatore::create(['nome' => 'Mario', 'cognome' => 'Rossi', 'attivo' => true]); $vecchio = AnnoTeocratico::create(['label' => '2024-2025', 'start_date' => '2024-09-01', 'end_date' => '2025-08-31']); $recente = AnnoTeocratico::create(['label' => '2025-2026', 'start_date' => '2025-09-01', 'end_date' => '2026-08-31']); // Create in disordine: l'ordine lo deve dare la pagina. foreach ([[$vecchio, '2024-10-01', '2024-11-01'], [$recente, '2025-10-01', '2025-11-15'], [$vecchio, '2025-03-01', '2025-04-01']] as [$anno, $dal, $al]) { Assegnazione::create([ 'territorio_id' => $this->territorio->id, 'proclamatore_id' => $this->proclamatore->id, 'anno_teocratico_id' => $anno->id, 'assigned_at' => $dal, 'returned_at' => $al, 'created_by' => $this->admin->id, ]); } } public function test_nella_scheda_del_territorio_una_tabella_sola_dal_piu_recente(): void { $html = $this->actingAs($this->admin)->get(route('territori.show', $this->territorio))->assertOk() ->assertSeeInOrder(['Anno Teocratico 2025-2026', '01/10/2025', 'Anno Teocratico 2024-2025', '01/03/2025', '01/10/2024']) ->getContent(); $this->assertSame(1, substr_count($html, '>Proclamatore'), "Un'intestazione sola: colonne in linea"); $this->assertSame(2, substr_count($html, 'tm-riga-gruppo')); } public function test_nella_scheda_del_proclamatore_una_tabella_sola_dal_piu_recente(): void { $html = $this->actingAs($this->admin)->get(route('proclamatori.show', $this->proclamatore))->assertOk() ->assertSeeInOrder(['Anno Teocratico 2025-2026', '01/10/2025', 'Anno Teocratico 2024-2025', '01/03/2025', '01/10/2024']) ->getContent(); $this->assertSame(1, substr_count($html, '>Territorio'), "Un'intestazione sola: colonne in linea"); $this->assertSame(2, substr_count($html, 'tm-riga-gruppo')); } }