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()); } }