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
|
|
@ -3,12 +3,14 @@
|
|||
use App\Enums\UserPaymentOptionStatus;
|
||||
use App\Models\BillingAddress;
|
||||
use App\Models\BookingConfirmation;
|
||||
use App\Models\LegalDocument;
|
||||
use App\Models\Plan;
|
||||
use App\Models\SinglePurchase;
|
||||
use App\Models\User;
|
||||
use App\Models\UserPaymentOption;
|
||||
use App\Services\Billing\CreditWalletService;
|
||||
use App\Services\Billing\StripeCheckoutService;
|
||||
use Database\Seeders\LegalDocumentSeeder;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
|
@ -296,6 +298,8 @@ test('checking the entrepreneur box records a booking confirmation with the agb
|
|||
/** @var TestCase $this */
|
||||
// T1neu (AGB v0.6 § 1 Abs. 4): Die Pflicht-Checkbox protokolliert
|
||||
// Zeitpunkt + AGB-Version — das B2B-Gate stützt sich auf diesen Nachweis.
|
||||
// E3: Zusätzlich wird die konkrete Rechtstext-Fassung referenziert.
|
||||
$this->seed(LegalDocumentSeeder::class);
|
||||
$user = bookingsTestCustomer();
|
||||
BillingAddress::factory()->create(['user_id' => $user->id]);
|
||||
config()->set('billing.single_pm_stripe_price_id', 'price_test_single_pm');
|
||||
|
|
@ -307,10 +311,12 @@ test('checking the entrepreneur box records a booking confirmation with the agb
|
|||
->set('entrepreneurConfirmed', true);
|
||||
|
||||
$confirmation = BookingConfirmation::query()->sole();
|
||||
$agb = LegalDocument::current(LegalDocument::TYPE_AGB);
|
||||
|
||||
expect($confirmation->user_id)->toBe($user->id);
|
||||
expect($confirmation->booking_type)->toBe('single_pm');
|
||||
expect($confirmation->agb_version)->toBe((string) config('legal.agb_version'));
|
||||
expect($confirmation->legal_document_id)->toBe($agb->id);
|
||||
expect($confirmation->agb_version)->toBe($agb->version);
|
||||
expect($confirmation->confirmed_at)->not->toBeNull();
|
||||
});
|
||||
|
||||
|
|
|
|||
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