Nelle schede di territorio e proclamatore ogni anno teocratico era una tabella a se', con le colonne dimensionate sul proprio contenuto. Ora una tabella con un'intestazione, colonne fisse, l'anno come riga di separazione (tm-riga-gruppo, titolo anche su telefono); ordine esplicito dal piu' recente. Nella scheda del proclamatore Campagna "Si'/No" e badge "via gruppo". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
3.1 KiB
PHP
75 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\AnnoTeocratico;
|
|
use App\Models\Assegnazione;
|
|
use App\Models\Proclamatore;
|
|
use App\Models\Setting;
|
|
use App\Models\Territorio;
|
|
use App\Models\User;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Lo storico delle assegnazioni nelle schede di territorio e proclamatore
|
|
* (20 ottobre 2026): una tabella sola con le colonne in linea, l'anno come
|
|
* riga di separazione, dal più recente.
|
|
*/
|
|
class StoricoAssegnazioniTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private User $admin;
|
|
|
|
private Territorio $territorio;
|
|
|
|
private Proclamatore $proclamatore;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->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</th>'), "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</th>'), "Un'intestazione sola: colonne in linea");
|
|
$this->assertSame(2, substr_count($html, 'tm-riga-gruppo'));
|
|
}
|
|
}
|