E3: Rechtstext-Versionierung in der DB (legal_documents)
Jede veroeffentlichte Fassung eines Rechtstexts ist eine Zeile mit type/version/effective_from — alte Fassungen sind unloeschbar, zukuenftige werden erst ab Stichtag wirksam (LegalDocument::current). Seeder legt die fuenf aktuellen Fassungen an (AGB 0.6, Datenschutz 0.3, Richtlinien 0.1, Meldeverfahren 0.1, Impressum 0.1). Die Unternehmer-Bestaetigung (T1neu) referenziert jetzt die konkrete Fassung (legal_document_id am Buchungsdatensatz, restrictOnDelete); AGB-Seite und Buchungs-Modal ziehen Version/Stand aus der DB. config/legal.php bleibt reiner Fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
7624064ea0
commit
196f83a377
12 changed files with 294 additions and 11 deletions
42
tests/Feature/Legal/LegalDocumentTest.php
Normal file
42
tests/Feature/Legal/LegalDocumentTest.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
use App\Models\LegalDocument;
|
||||
use Database\Seeders\LegalDocumentSeeder;
|
||||
use Tests\TestCase;
|
||||
|
||||
test('current returns the newest effective version and ignores future ones', function () {
|
||||
LegalDocument::factory()->agb()->create(['version' => '0.5', 'effective_from' => '2026-06-01']);
|
||||
$current = LegalDocument::factory()->agb()->create(['version' => '0.6', 'effective_from' => '2026-07-03']);
|
||||
// Zukünftige Fassung: veröffentlicht, aber noch nicht wirksam.
|
||||
LegalDocument::factory()->agb()->create(['version' => '0.7', 'effective_from' => now()->addMonth()->toDateString()]);
|
||||
|
||||
expect(LegalDocument::current(LegalDocument::TYPE_AGB)?->id)->toBe($current->id);
|
||||
expect(LegalDocument::currentAgbVersion())->toBe('0.6');
|
||||
});
|
||||
|
||||
test('the agb version falls back to the config while the table is empty', function () {
|
||||
config()->set('legal.agb_version', '9.9');
|
||||
|
||||
expect(LegalDocument::current(LegalDocument::TYPE_AGB))->toBeNull();
|
||||
expect(LegalDocument::currentAgbVersion())->toBe('9.9');
|
||||
});
|
||||
|
||||
test('the seeder registers all five legal documents idempotently', function () {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(LegalDocumentSeeder::class);
|
||||
$this->seed(LegalDocumentSeeder::class); // Wiederholung darf nichts duplizieren.
|
||||
|
||||
expect(LegalDocument::query()->count())->toBe(5);
|
||||
expect(LegalDocument::currentAgbVersion())->toBe('0.6');
|
||||
expect(LegalDocument::current(LegalDocument::TYPE_DATENSCHUTZ)?->version)->toBe('0.3');
|
||||
});
|
||||
|
||||
test('the agb page renders version and effective date from the database', function () {
|
||||
/** @var TestCase $this */
|
||||
LegalDocument::factory()->agb()->create(['version' => '0.6', 'effective_from' => '2026-07-03']);
|
||||
|
||||
$this->get('https://pressekonto.test/de/agb')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('Version 0.6')
|
||||
->assertSeeText('Stand: 3. Juli 2026');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue