Posta configurabile dall'app, contatti dei proclamatori, conferma email
- Server di posta in Impostazioni (password cifrata, email di prova): se compilato prende il posto del .env; non si esporta e l'import XML non lo cancella. MAIL_SCHEME=tls nel .env.example non era valido per Laravel 11. - Proclamatori con email e telefono facoltativi, cifrati, nell'XML e cancellati dall'anonimizzazione; il numero apre WhatsApp. - Dopo l'assegnazione un riquadro in evidenza con il link del PDF, "Invia su WhatsApp" con il messaggio pronto e la scelta "inviato / non ancora", che resta finché non si sceglie. - Conferma dell'email obbligatoria per tutti gli utenti, anche esistenti: email in italiano, link valido senza login, nuova conferma a ogni cambio di indirizzo, "Reinvia conferma" in Utenti. Senza conferma restano raggiungibili profilo, cambio password e, per l'admin, il server di posta; comando utenti:conferma-email per l'emergenza. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
174
tests/Feature/ConfermaEmailTest.php
Normal file
174
tests/Feature/ConfermaEmailTest.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Livewire\Profile;
|
||||
use App\Livewire\Settings\UsersIndex;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Illuminate\Auth\Notifications\VerifyEmail;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Un account funziona solo con l'indirizzo email confermato.
|
||||
*/
|
||||
class ConfermaEmailTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected bool $confermaUtentiCreati = false;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutVite();
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
Setting::firstOrCreate([], ['congregazione_nome' => 'Congregazione di prova']);
|
||||
}
|
||||
|
||||
private function utente(string $ruolo = 'operatore', bool $confermato = false): User
|
||||
{
|
||||
$utente = User::create([
|
||||
'name' => 'Mario Rossi',
|
||||
'email' => $ruolo . '@example.test',
|
||||
'password' => 'password-di-prova',
|
||||
]);
|
||||
$utente->assignRole($ruolo);
|
||||
|
||||
if ($confermato) {
|
||||
$utente->markEmailAsVerified();
|
||||
}
|
||||
|
||||
return $utente->fresh();
|
||||
}
|
||||
|
||||
private function linkDiConferma(User $utente, ?string $email = null): string
|
||||
{
|
||||
return URL::temporarySignedRoute('verification.verify', now()->addHour(), [
|
||||
'id' => $utente->id,
|
||||
'hash' => sha1($email ?? $utente->email),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_senza_conferma_l_account_non_funziona(): void
|
||||
{
|
||||
$utente = $this->utente();
|
||||
|
||||
$this->actingAs($utente)->get(route('dashboard'))->assertRedirect(route('verification.notice'));
|
||||
$this->actingAs($utente)->get(route('territori.index'))->assertRedirect(route('verification.notice'));
|
||||
$this->actingAs($utente)->get(route('verification.notice'))->assertOk()->assertSee('Conferma il tuo indirizzo email');
|
||||
$this->actingAs($utente)->get(route('profile'))->assertOk();
|
||||
}
|
||||
|
||||
public function test_un_amministratore_non_confermato_puo_configurare_la_posta(): void
|
||||
{
|
||||
$admin = $this->utente('amministratore');
|
||||
|
||||
$this->actingAs($admin)->get(route('settings.edit'))->assertRedirect(route('verification.notice'));
|
||||
$this->actingAs($admin)->get(route('posta.edit'))->assertOk()->assertSee('Server di posta');
|
||||
}
|
||||
|
||||
public function test_il_link_conferma_anche_senza_essere_entrati(): void
|
||||
{
|
||||
$utente = $this->utente();
|
||||
|
||||
$this->get($this->linkDiConferma($utente))->assertRedirect(route('login'));
|
||||
|
||||
$this->assertTrue($utente->fresh()->hasVerifiedEmail());
|
||||
$this->actingAs($utente->fresh())->get(route('dashboard'))->assertOk();
|
||||
}
|
||||
|
||||
public function test_un_link_alterato_o_di_un_altro_indirizzo_non_conferma(): void
|
||||
{
|
||||
$utente = $this->utente();
|
||||
|
||||
$link = $this->linkDiConferma($utente);
|
||||
$this->get(str_replace('/' . $utente->id . '/', '/999/', $link))->assertForbidden();
|
||||
|
||||
$this->get($this->linkDiConferma($utente, 'vecchio@example.test'))->assertForbidden();
|
||||
|
||||
$this->assertFalse($utente->fresh()->hasVerifiedEmail());
|
||||
}
|
||||
|
||||
public function test_richiedere_l_email_la_manda(): void
|
||||
{
|
||||
Notification::fake();
|
||||
$utente = $this->utente();
|
||||
|
||||
$this->actingAs($utente)->post(route('verification.send'))->assertSessionHas('success');
|
||||
|
||||
Notification::assertSentTo($utente, VerifyEmail::class);
|
||||
}
|
||||
|
||||
public function test_l_amministratore_crea_un_utente_e_gli_parte_la_conferma(): void
|
||||
{
|
||||
Notification::fake();
|
||||
$admin = $this->utente('amministratore', confermato: true);
|
||||
|
||||
Livewire::actingAs($admin)->test(UsersIndex::class)
|
||||
->set('name', 'Giulia Bianchi')
|
||||
->set('email', 'giulia@example.test')
|
||||
->set('password', 'password-di-prova')
|
||||
->set('password_confirmation', 'password-di-prova')
|
||||
->set('selectedRole', 'operatore')
|
||||
->call('createUser')
|
||||
->assertHasNoErrors()
|
||||
->assertDispatched('avviso');
|
||||
|
||||
$nuovo = User::where('email', 'giulia@example.test')->sole();
|
||||
$this->assertFalse($nuovo->hasVerifiedEmail());
|
||||
Notification::assertSentTo($nuovo, VerifyEmail::class);
|
||||
}
|
||||
|
||||
public function test_cambiare_email_la_rende_da_confermare(): void
|
||||
{
|
||||
Notification::fake();
|
||||
$utente = $this->utente(confermato: true);
|
||||
|
||||
Livewire::actingAs($utente)->test(Profile::class)
|
||||
->set('name', 'Mario Rossi')
|
||||
->set('email', 'nuovo@example.test')
|
||||
->call('updateProfile')
|
||||
->assertRedirect(route('verification.notice'));
|
||||
|
||||
$this->assertFalse($utente->fresh()->hasVerifiedEmail());
|
||||
Notification::assertSentTo($utente->fresh(), VerifyEmail::class);
|
||||
}
|
||||
|
||||
public function test_cambiare_solo_il_nome_non_tocca_la_conferma(): void
|
||||
{
|
||||
$utente = $this->utente(confermato: true);
|
||||
|
||||
Livewire::actingAs($utente)->test(Profile::class)
|
||||
->set('name', 'Mario Verdi')
|
||||
->set('email', $utente->email)
|
||||
->call('updateProfile');
|
||||
|
||||
$this->assertTrue($utente->fresh()->hasVerifiedEmail());
|
||||
}
|
||||
|
||||
public function test_il_comando_di_emergenza_conferma_un_utente(): void
|
||||
{
|
||||
$utente = $this->utente();
|
||||
|
||||
$this->artisan('utenti:conferma-email', ['email' => $utente->email])->assertSuccessful();
|
||||
|
||||
$this->assertTrue($utente->fresh()->hasVerifiedEmail());
|
||||
}
|
||||
|
||||
public function test_il_primo_amministratore_da_riga_di_comando_nasce_confermato(): void
|
||||
{
|
||||
$this->artisan('app:create-initial-admin', [
|
||||
'--name' => 'Admin',
|
||||
'--email' => 'primo@example.test',
|
||||
'--password' => 'password-di-prova',
|
||||
])->assertSuccessful();
|
||||
|
||||
$this->assertTrue(User::where('email', 'primo@example.test')->sole()->hasVerifiedEmail());
|
||||
}
|
||||
}
|
||||
210
tests/Feature/ContattiProclamatoriTest.php
Normal file
210
tests/Feature/ContattiProclamatoriTest.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Livewire\Assegnazioni\Assegna;
|
||||
use App\Livewire\Proclamatori\ProclamatoreCreate;
|
||||
use App\Livewire\Settings\XmlExchange;
|
||||
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 Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Email e telefono dei proclamatori (facoltativi), WhatsApp, e il riquadro
|
||||
* con il link da mandare subito dopo l'assegnazione.
|
||||
*/
|
||||
class ContattiProclamatoriTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $admin;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutVite();
|
||||
Storage::fake('public');
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
Setting::firstOrCreate([], ['congregazione_nome' => 'Congregazione di prova']);
|
||||
AnnoTeocratico::create(['label' => '2026-2027', 'start_date' => '2026-09-01', 'end_date' => '2027-08-31']);
|
||||
|
||||
$this->admin = User::create(['name' => 'Admin', 'email' => 'admin@example.test', 'password' => 'password-di-prova']);
|
||||
$this->admin->assignRole('amministratore');
|
||||
}
|
||||
|
||||
// ─── Contatti ───────────────────────────────────────────────
|
||||
|
||||
public function test_email_e_telefono_sono_facoltativi_e_cifrati(): void
|
||||
{
|
||||
Livewire::actingAs($this->admin)->test(ProclamatoreCreate::class)
|
||||
->set('nome', 'Mario')->set('cognome', 'Rossi')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
Livewire::actingAs($this->admin)->test(ProclamatoreCreate::class)
|
||||
->set('nome', 'Anna')->set('cognome', 'Verdi')
|
||||
->set('email', 'anna@example.test')
|
||||
->set('telefono', '333 123 4567')
|
||||
->call('save')
|
||||
->assertHasNoErrors();
|
||||
|
||||
$anna = Proclamatore::all()->first(fn ($p) => $p->nome === 'Anna');
|
||||
$this->assertSame('anna@example.test', $anna->email);
|
||||
$this->assertSame('333 123 4567', $anna->telefono);
|
||||
|
||||
$riga = DB::table('proclamatori')->where('id', $anna->id)->first();
|
||||
$this->assertStringNotContainsString('anna@', $riga->email);
|
||||
$this->assertStringNotContainsString('333', $riga->telefono);
|
||||
}
|
||||
|
||||
public function test_un_email_sbagliata_si_segnala_ma_si_puo_lasciare_vuota(): void
|
||||
{
|
||||
Livewire::actingAs($this->admin)->test(ProclamatoreCreate::class)
|
||||
->set('nome', 'Mario')->set('cognome', 'Rossi')
|
||||
->set('email', 'non-una-email')
|
||||
->call('save')
|
||||
->assertHasErrors('email');
|
||||
|
||||
$this->assertSame(0, Proclamatore::count());
|
||||
}
|
||||
|
||||
#[DataProvider('numeri')]
|
||||
public function test_il_numero_diventa_internazionale_per_whatsapp(string $scritto, ?string $atteso): void
|
||||
{
|
||||
$p = new Proclamatore(['nome' => 'A', 'cognome' => 'B', 'telefono' => $scritto]);
|
||||
|
||||
$this->assertSame($atteso, $p->telefonoInternazionale());
|
||||
$this->assertSame($atteso ? 'https://wa.me/' . $atteso : null, $p->whatsappUrl());
|
||||
}
|
||||
|
||||
public static function numeri(): array
|
||||
{
|
||||
return [
|
||||
'cellulare italiano' => ['333 123 4567', '393331234567'],
|
||||
'con +39' => ['+39 333 1234567', '393331234567'],
|
||||
'con 0039' => ['0039 3331234567', '393331234567'],
|
||||
'39 senza +' => ['393331234567', '393331234567'],
|
||||
'cellulare che inizia con 39' => ['392 1234567', '393921234567'],
|
||||
'fisso italiano' => ['06 12345678', '390612345678'],
|
||||
'estero' => ['+44 7911 123456', '447911123456'],
|
||||
'troppo corto' => ['123', null],
|
||||
'vuoto' => ['', null],
|
||||
];
|
||||
}
|
||||
|
||||
public function test_il_messaggio_whatsapp_contiene_il_link(): void
|
||||
{
|
||||
$p = new Proclamatore(['nome' => 'A', 'cognome' => 'B', 'telefono' => '3331234567']);
|
||||
|
||||
$this->assertSame(
|
||||
'https://wa.me/393331234567?text=' . rawurlencode('Ecco: https://x.test/p/AB12'),
|
||||
$p->whatsappUrl('Ecco: https://x.test/p/AB12'),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_anonimizzare_cancella_anche_i_contatti(): void
|
||||
{
|
||||
$p = Proclamatore::create(['nome' => 'Mario', 'cognome' => 'Rossi', 'attivo' => true, 'email' => 'm@example.test', 'telefono' => '3331234567']);
|
||||
|
||||
$p->anonimizza();
|
||||
|
||||
$p = Proclamatore::withTrashed()->find($p->id);
|
||||
$this->assertNull($p->email);
|
||||
$this->assertNull($p->telefono);
|
||||
}
|
||||
|
||||
public function test_l_xml_porta_con_se_i_contatti(): void
|
||||
{
|
||||
$this->actingAs($this->admin);
|
||||
Proclamatore::create(['nome' => 'Mario', 'cognome' => 'Rossi', 'attivo' => true, 'email' => 'm@example.test', 'telefono' => '3331234567']);
|
||||
|
||||
$xml = (new XmlExchange())->currentXmlBackup();
|
||||
$this->assertArrayNotHasKey('error', (new XmlExchange())->importXmlFromContent($xml));
|
||||
|
||||
$p = Proclamatore::sole();
|
||||
$this->assertSame('m@example.test', $p->email);
|
||||
$this->assertSame('3331234567', $p->telefono);
|
||||
}
|
||||
|
||||
// ─── Dopo l'assegnazione ────────────────────────────────────
|
||||
|
||||
private function assegna(Proclamatore $proclamatore, Territorio $territorio)
|
||||
{
|
||||
return Livewire::actingAs($this->admin)->test(Assegna::class)
|
||||
->set('territorio_id', $territorio->id)
|
||||
->set('proclamatore_id', $proclamatore->id)
|
||||
->set('assigned_at', now()->format('Y-m-d'))
|
||||
->call('save');
|
||||
}
|
||||
|
||||
private function territorioConPdf(string $numero = '7'): Territorio
|
||||
{
|
||||
Storage::disk('public')->put("territori-pdf/t{$numero}.pdf", '%PDF-1.4');
|
||||
|
||||
return Territorio::create(['numero' => $numero, 'attivo' => true, 'pdf_path' => "territori-pdf/t{$numero}.pdf"]);
|
||||
}
|
||||
|
||||
public function test_dopo_l_assegnazione_compare_il_link_da_mandare_su_whatsapp(): void
|
||||
{
|
||||
$mario = Proclamatore::create(['nome' => 'Mario', 'cognome' => 'Rossi', 'attivo' => true, 'telefono' => '333 1234567']);
|
||||
$territorio = $this->territorioConPdf();
|
||||
|
||||
$this->assegna($mario, $territorio)
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect(route('assegnazioni.assegna'));
|
||||
|
||||
$assegnazione = Assegnazione::sole();
|
||||
$this->assertSame([$assegnazione->id], session(Assegna::DA_INVIARE));
|
||||
|
||||
$link = $assegnazione->fresh()->shortPdfUrl();
|
||||
Livewire::actingAs($this->admin)->test(Assegna::class)
|
||||
->assertSee('Territorio N° 7 assegnato a Rossi Mario')
|
||||
->assertSee($link)
|
||||
->assertSee('https://wa.me/393331234567?text=', false)
|
||||
->assertSee(rawurlencode($link), false)
|
||||
->assertSee('Il link è stato inviato?');
|
||||
}
|
||||
|
||||
public function test_la_scelta_registra_l_invio_e_toglie_il_riquadro(): void
|
||||
{
|
||||
$mario = Proclamatore::create(['nome' => 'Mario', 'cognome' => 'Rossi', 'attivo' => true, 'telefono' => '3331234567']);
|
||||
$anna = Proclamatore::create(['nome' => 'Anna', 'cognome' => 'Verdi', 'attivo' => true]);
|
||||
$this->assegna($mario, $this->territorioConPdf('7'));
|
||||
$this->assegna($anna, $this->territorioConPdf('8'));
|
||||
|
||||
[$prima, $seconda] = Assegnazione::orderBy('id')->get()->all();
|
||||
|
||||
Livewire::actingAs($this->admin)->test(Assegna::class)
|
||||
->assertSee('Territorio N° 7 assegnato')
|
||||
->assertSee('Territorio N° 8 assegnato')
|
||||
->call('esitoInvio', $prima->id, true)
|
||||
->assertDontSee('Territorio N° 7 assegnato')
|
||||
->assertSee('Territorio N° 8 assegnato')
|
||||
->call('esitoInvio', $seconda->id, false)
|
||||
->assertDontSee('Territorio N° 8 assegnato');
|
||||
|
||||
$this->assertTrue((bool) $prima->fresh()->link_sent);
|
||||
$this->assertFalse((bool) $seconda->fresh()->link_sent);
|
||||
$this->assertSame([], session(Assegna::DA_INVIARE));
|
||||
}
|
||||
|
||||
public function test_senza_telefono_il_riquadro_lo_dice(): void
|
||||
{
|
||||
$anna = Proclamatore::create(['nome' => 'Anna', 'cognome' => 'Verdi', 'attivo' => true]);
|
||||
$this->assegna($anna, $this->territorioConPdf());
|
||||
|
||||
Livewire::actingAs($this->admin)->test(Assegna::class)
|
||||
->assertSee('non ha un numero di telefono')
|
||||
->assertDontSee('wa.me', false);
|
||||
}
|
||||
}
|
||||
149
tests/Feature/PostaElettronicaTest.php
Normal file
149
tests/Feature/PostaElettronicaTest.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Livewire\Settings\PostaElettronica;
|
||||
use App\Livewire\Settings\XmlExchange;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Services\ConfigurazionePosta;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Il server di posta si configura dall'applicazione e prende il posto del .env.
|
||||
*/
|
||||
class PostaElettronicaTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $admin;
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
private function salva(array $valori = []): void
|
||||
{
|
||||
$componente = Livewire::actingAs($this->admin)->test(PostaElettronica::class);
|
||||
foreach ($valori + [
|
||||
'host' => 'smtp.esempio.it',
|
||||
'porta' => '587',
|
||||
'cifratura' => ConfigurazionePosta::CIFRATURA_AUTOMATICA,
|
||||
'utente' => 'territori@esempio.it',
|
||||
'password' => 'segreta-123',
|
||||
'mittente' => 'territori@esempio.it',
|
||||
'nomeMittente' => 'Territori',
|
||||
] as $campo => $valore) {
|
||||
$componente->set($campo, $valore);
|
||||
}
|
||||
$componente->call('salva')->assertHasNoErrors();
|
||||
}
|
||||
|
||||
public function test_la_pagina_e_dell_amministratore(): void
|
||||
{
|
||||
$operatore = User::create(['name' => 'Op', 'email' => 'op@example.test', 'password' => 'password-di-prova']);
|
||||
$operatore->assignRole('operatore');
|
||||
|
||||
$this->actingAs($operatore)->get(route('posta.edit'))->assertForbidden();
|
||||
$this->flushSession(); // due utenti nella stessa sessione: AuthenticateSession
|
||||
$this->actingAs($this->admin)->get(route('posta.edit'))->assertOk();
|
||||
}
|
||||
|
||||
public function test_la_configurazione_salvata_prende_il_posto_del_env(): void
|
||||
{
|
||||
config(['mail.default' => 'log']);
|
||||
|
||||
$this->salva();
|
||||
app(ConfigurazionePosta::class)->applica();
|
||||
|
||||
$this->assertSame('smtp', config('mail.default'));
|
||||
$this->assertSame('smtp.esempio.it', config('mail.mailers.smtp.host'));
|
||||
$this->assertSame(587, config('mail.mailers.smtp.port'));
|
||||
$this->assertSame('smtp', config('mail.mailers.smtp.scheme'));
|
||||
$this->assertSame('segreta-123', config('mail.mailers.smtp.password'));
|
||||
$this->assertSame('territori@esempio.it', config('mail.from.address'));
|
||||
}
|
||||
|
||||
public function test_ssl_usa_smtps_e_la_porta_465(): void
|
||||
{
|
||||
$this->salva(['cifratura' => ConfigurazionePosta::CIFRATURA_SSL, 'porta' => '']);
|
||||
app(ConfigurazionePosta::class)->applica();
|
||||
|
||||
$this->assertSame('smtps', config('mail.mailers.smtp.scheme'));
|
||||
$this->assertSame(465, config('mail.mailers.smtp.port'));
|
||||
}
|
||||
|
||||
public function test_la_password_e_cifrata_e_non_torna_al_browser(): void
|
||||
{
|
||||
$this->salva();
|
||||
|
||||
$grezza = DB::table('settings')->value('mail_password');
|
||||
$this->assertNotSame('segreta-123', $grezza);
|
||||
$this->assertStringNotContainsString('segreta', $grezza);
|
||||
|
||||
Livewire::actingAs($this->admin)->test(PostaElettronica::class)
|
||||
->assertSet('password', '')
|
||||
->assertDontSee('segreta-123');
|
||||
}
|
||||
|
||||
public function test_lasciare_vuota_la_password_tiene_quella_salvata(): void
|
||||
{
|
||||
$this->salva();
|
||||
$this->salva(['password' => '', 'host' => 'smtp.altro.it']);
|
||||
|
||||
Setting::flushCache();
|
||||
$this->assertSame('segreta-123', Setting::instance()->mail_password);
|
||||
$this->assertSame('smtp.altro.it', Setting::instance()->mail_host);
|
||||
}
|
||||
|
||||
public function test_l_email_di_prova_parte(): void
|
||||
{
|
||||
Mail::fake();
|
||||
$this->salva();
|
||||
|
||||
Livewire::actingAs($this->admin)->test(PostaElettronica::class)
|
||||
->call('inviaProva')
|
||||
->assertDispatched('avviso', tipo: 'ok');
|
||||
}
|
||||
|
||||
public function test_l_export_xml_non_contiene_la_posta_e_l_import_non_la_cancella(): void
|
||||
{
|
||||
$this->salva();
|
||||
$this->actingAs($this->admin);
|
||||
|
||||
$xml = (new XmlExchange())->currentXmlBackup();
|
||||
$this->assertStringNotContainsString('smtp.esempio.it', $xml);
|
||||
$this->assertStringNotContainsString('mail_host', $xml);
|
||||
$this->assertStringNotContainsString('segreta', $xml);
|
||||
|
||||
$esito = (new XmlExchange())->importXmlFromContent($xml);
|
||||
$this->assertArrayNotHasKey('error', $esito);
|
||||
|
||||
Setting::flushCache();
|
||||
$this->assertSame('smtp.esempio.it', Setting::instance()->mail_host);
|
||||
$this->assertSame('segreta-123', Setting::instance()->mail_password);
|
||||
}
|
||||
|
||||
public function test_rimuovere_torna_al_env(): void
|
||||
{
|
||||
$this->salva();
|
||||
|
||||
Livewire::actingAs($this->admin)->test(PostaElettronica::class)->call('rimuovi');
|
||||
|
||||
Setting::flushCache();
|
||||
$this->assertNull(Setting::instance()->mail_host);
|
||||
$this->assertFalse(app(ConfigurazionePosta::class)->configurataNellApp());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user