CI Feature / test (push) Successful in 4m41s
Der Registry-Test erlaubt bewusst Widgets, die nur aus einem Verweis bestehen (Anfrage: nur die Kennung eines Einstiegs) und kennt die neue Widget-Art. ADR-60, Beschreibung der Kommunikationsverwaltung, Rückfall und Migration in der Release-Vorbereitung. Der Browser meldet laufende Zustandsabfragen über aria-busy. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
57 lines
2.2 KiB
PHP
57 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Communication\CommunicationSettings;
|
|
use App\Domain\Communication\ExampleConfiguration;
|
|
use App\Domain\Communication\FormToken;
|
|
use App\Domain\Communication\Inquiry;
|
|
use App\Domain\Communication\InquiryEntry;
|
|
use App\Domain\Communication\InquiryService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class CommunicationPurgeTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
private function inquiry(string $email): Inquiry
|
|
{
|
|
config(['communication.min_fill_seconds' => 0]);
|
|
$entry = InquiryEntry::query()->where('key', 'allgemeiner_kontakt')->firstOrFail();
|
|
$result = app(InquiryService::class)->submit($entry, [
|
|
'token' => FormToken::issue($entry->id, $entry->template->published_version_id),
|
|
'values' => ['name' => 'Mira', 'email' => $email, 'nachricht' => 'Hallo'],
|
|
]);
|
|
|
|
return Inquiry::query()->where('reference', $result['reference'])->firstOrFail();
|
|
}
|
|
|
|
public function test_nothing_is_deleted_without_a_retention_period(): void
|
|
{
|
|
app(ExampleConfiguration::class)->install();
|
|
$old = $this->inquiry('alt@example.org');
|
|
$old->forceFill(['created_at' => now()->subYears(5)])->save();
|
|
|
|
$this->artisan('communication:purge')->expectsOutputToContain('nichts gelöscht')->assertSuccessful();
|
|
|
|
$this->assertSame(1, Inquiry::query()->count());
|
|
}
|
|
|
|
public function test_only_inquiries_older_than_the_retention_period_are_deleted(): void
|
|
{
|
|
app(ExampleConfiguration::class)->install();
|
|
CommunicationSettings::current()->update(['retention_months' => 12]);
|
|
$old = $this->inquiry('alt@example.org');
|
|
$old->forceFill(['created_at' => now()->subMonths(13)])->save();
|
|
$this->inquiry('neu@example.org');
|
|
|
|
$this->artisan('communication:purge', ['--pretend' => true])->expectsOutputToContain('1 Anfragen wären älter')->assertSuccessful();
|
|
$this->assertSame(2, Inquiry::query()->count());
|
|
|
|
$this->artisan('communication:purge')->expectsOutputToContain('1 Anfragen gelöscht')->assertSuccessful();
|
|
|
|
$this->assertSame(['neu@example.org'], Inquiry::query()->pluck('contact_email')->all());
|
|
}
|
|
}
|