tests/legal: Testdatenbank-Guard vor den DB-Traits, Flags in phpunit.xml gepinnt, Zustimmung an gezeigte Fassung gebunden (Umsetzungsaudit 25.09.: N22, N06, 5.3)
- Tests\TestCase prüft die Standardverbindung in setUpTraits(), also vor RefreshDatabase — bisher erst nach dem Refresh (N22). Eigener Test. - phpunit.xml pinnt IMAGE_RIGHTS_V2, IMAGE_PRECHECK(_STAGE) und LEGAL_ACCEPTANCE_GATE auf die Vorgaben aus .env.example; die Suite hing sonst an der lokalen .env (Audit Abschnitt 6). - Zustimmungsgate: die Livewire-Komponenten tragen die beim Rendern gezeigten Fassungen (Trait-Hook rendering); weicht die aktuelle Fassung beim Absenden ab, wird die Annahme abgelehnt und der neue Wortlaut gezeigt. Ein fehlendes Pflichtdokument ist bei aktivem Gate ein Konfigurationsfehler (N06). - Audit vom 25.09., Decision-Update vom 22.09. und Plan Fassung 2 versioniert; die Antwortkopie „…-211.md" entfernt; U10-Formulierung im Plan präzisiert. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
d99f55e555
commit
4e34c3d0d1
10 changed files with 1436 additions and 10 deletions
|
|
@ -8,6 +8,7 @@ use App\Models\LegalDocumentAcceptance;
|
|||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Zustimmungsgate vor jeder Einreichung (Bildkennzeichnung Block G,
|
||||
|
|
@ -41,12 +42,37 @@ class LegalAcceptanceGate
|
|||
}
|
||||
|
||||
return collect(self::TYPES)
|
||||
->map(fn (string $type): ?LegalDocument => LegalDocument::current($type))
|
||||
->filter()
|
||||
->map(function (string $type): LegalDocument {
|
||||
// Ein fehlendes Pflichtdokument ist ein Konfigurationsfehler und
|
||||
// darf das Gate nicht still verkleinern (Umsetzungsaudit
|
||||
// 25.09.2026, N06).
|
||||
return LegalDocument::current($type)
|
||||
?? throw new RuntimeException(sprintf('Zustimmungsgate: kein gültiges Dokument vom Typ „%s“ hinterlegt (legal_documents).', $type));
|
||||
})
|
||||
->reject(fn (LegalDocument $document): bool => $this->hasAccepted($user, $document))
|
||||
->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fassungen je Typ, wie sie dem Nutzer gerade gezeigt werden — die
|
||||
* Bestätigung im Browser wird an genau diese Kennungen gebunden.
|
||||
*
|
||||
* @param iterable<int, LegalDocument> $documents
|
||||
* @return array<string, string> type => version
|
||||
*/
|
||||
public static function versionsOf(iterable $documents): array
|
||||
{
|
||||
$versions = [];
|
||||
|
||||
foreach ($documents as $document) {
|
||||
$versions[$document->type] = $document->version;
|
||||
}
|
||||
|
||||
ksort($versions);
|
||||
|
||||
return $versions;
|
||||
}
|
||||
|
||||
public function hasAccepted(User $user, LegalDocument $document): bool
|
||||
{
|
||||
return LegalDocumentAcceptance::query()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue