47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
||
|
||
namespace Tests\Feature\Process;
|
||
|
||
use App\Actions\AnonymizeGuests;
|
||
use App\Models\Channel;
|
||
use App\Models\ProcessTestRun;
|
||
use App\Models\Property;
|
||
use App\Models\User;
|
||
use App\Support\SystemSettings;
|
||
use Carbon\CarbonImmutable;
|
||
use Database\Seeders\PropertySeeder;
|
||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
use PHPUnit\Framework\Attributes\Group;
|
||
use Tests\TestCase;
|
||
|
||
/**
|
||
* Decision O3: reports of the process tester are deleted after 30 days by the existing retention job; the period is
|
||
* part of the retention settings (System › Löschfristen).
|
||
*/
|
||
#[Group('sandbox')]
|
||
class ProcessTestRunRetentionTest extends TestCase
|
||
{
|
||
use RefreshDatabase;
|
||
|
||
public function test_reports_older_than_the_retention_period_are_deleted(): void
|
||
{
|
||
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||
$this->seed(PropertySeeder::class);
|
||
$channel = Channel::websiteOf(Property::sole());
|
||
$user = User::factory()->create();
|
||
$run = fn (): ProcessTestRun => ProcessTestRun::query()->create(['tenant_id' => $channel->tenant_id, 'channel_id' => $channel->id, 'user_id' => $user->id, 'intake' => 'inquiry', 'scenario' => 'complete_request', 'configuration' => [], 'inputs' => [], 'steps' => 1, 'report' => [], 'outcome' => ProcessTestRun::COMPLETED]);
|
||
|
||
$old = $run();
|
||
$this->travel(29)->days();
|
||
$recent = $run();
|
||
$this->travel(2)->days();
|
||
|
||
$this->assertSame(30, config('fewo.retention.process_test_run_days'));
|
||
$this->assertArrayHasKey('fewo.retention.process_test_run_days', SystemSettings::EDITABLE);
|
||
app(AnonymizeGuests::class)->handle();
|
||
|
||
$this->assertModelMissing($old);
|
||
$this->assertModelExists($recent);
|
||
}
|
||
}
|