withoutVite(); $this->seed(RolesAndPermissionsSeeder::class); $this->admin = User::create(['name' => 'Admin', 'email' => 'admin@example.test', 'password' => 'password-di-prova']); $this->admin->assignRole('amministratore'); } public function test_i_valori_arrivano_dalle_impostazioni(): void { Setting::firstOrCreate([], ['congregazione_nome' => 'x'])->update([ 'congregazione_nome' => 'Congregazione Zisa', 'audit_retention_days' => 400, 'giorni_per_smarrito' => 95, 'pdf_viewer_show_download' => false, ]); $this->actingAs($this->admin)->get(route('privacy')) ->assertOk() ->assertSee('Congregazione Zisa') ->assertSee('conservato per') ->assertSee('400 giorni') ->assertSee('al massimo per 95 giorni') ->assertSee('si può solo consultare, non scaricare'); } public function test_cambiare_un_impostazione_cambia_l_informativa(): void { $impostazioni = Setting::firstOrCreate([], ['congregazione_nome' => 'Prova']); $impostazioni->update(['pdf_viewer_show_download' => true, 'giorni_per_smarrito' => 60]); $this->actingAs($this->admin)->get(route('privacy')) ->assertSee('al massimo per 60 giorni') ->assertSee('si può anche scaricare'); } public function test_i_ruoli_sono_quelli_veri_con_i_loro_permessi(): void { Setting::firstOrCreate([], ['congregazione_nome' => 'Prova']); $this->actingAs($this->admin)->get(route('privacy')) ->assertSee('Amministratore') ->assertSee('Assistente') ->assertSee('Operatore') ->assertSee('assegnazione dei territori') ->assertDontSee('Servitore di Territorio') ->assertDontSee('Proclamatore Semplificato'); } public function test_conta_i_dati_conservati_senza_mostrarli(): void { Setting::firstOrCreate([], ['congregazione_nome' => 'Prova']); Proclamatore::create(['nome' => 'Mario', 'cognome' => 'Rossi', 'attivo' => true]); Proclamatore::create(['nome' => 'Anna', 'cognome' => 'Verdi', 'attivo' => false]); $this->actingAs($this->admin)->get(route('privacy')) ->assertSee('2 proclamatori, di cui 1 attivi;') ->assertSee('Nessun numero di telefono né indirizzo email') ->assertDontSee('Rossi'); } public function test_senza_posta_dice_che_non_si_inviano_email(): void { Setting::firstOrCreate([], ['congregazione_nome' => 'Prova']); config(['mail.default' => 'log']); $this->actingAs($this->admin)->get(route('privacy')) ->assertSee('nessun server di posta configurato'); } public function test_con_la_posta_dell_app_ne_mostra_il_server(): void { Setting::firstOrCreate([], ['congregazione_nome' => 'Prova']) ->update(['mail_host' => 'smtp.example.test', 'mail_port' => 587]); $this->actingAs($this->admin)->get(route('privacy')) ->assertSee('smtp.example.test'); } public function test_e_riservata_all_amministratore(): void { Setting::firstOrCreate([], ['congregazione_nome' => 'Prova']); $operatore = User::create(['name' => 'Op', 'email' => 'op@example.test', 'password' => 'password-di-prova']); $operatore->assignRole('operatore'); $this->actingAs($operatore)->get(route('privacy'))->assertForbidden(); } }