Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ca7a8b268 | ||
|
|
cc890d9fc7 | ||
|
|
37056761a3 | ||
|
|
1413e0640f | ||
|
|
631502c064 | ||
|
|
4bc2e5871b |
No files matched your search
@@ -107,20 +107,31 @@ protected function imageSourceFields(): array
|
||||
->view('filament.cms.filmbild-feld')
|
||||
->dehydrated(false)
|
||||
->visible(fn (Get $get): bool => $this->filmFor($get('element')) !== null)
|
||||
->viewData(function (Get $get): array {
|
||||
$film = $this->filmFor($get('element'));
|
||||
$stills = app(FilmStill::class);
|
||||
$version = $film instanceof ContentElement ? $stills->version($film) : null;
|
||||
->viewData(fn (Get $get): array => $this->filmFieldData($this->filmFor($get('element')))),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'film' => $film,
|
||||
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
|
||||
'filmVersionId' => $version?->id,
|
||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||
];
|
||||
}),
|
||||
/**
|
||||
* Anzeigedaten des Felds „Bild aus dem Film“. Die Stelle kommt aus der bereitgestellten Fassung, bei einem Film
|
||||
* nur mit Website-Datei aus dieser (Route content.website-frame).
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function filmFieldData(?ContentElement $film): array
|
||||
{
|
||||
$stills = app(FilmStill::class);
|
||||
$version = $film instanceof ContentElement ? $stills->version($film) : null;
|
||||
|
||||
return [
|
||||
'film' => $film,
|
||||
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
|
||||
'filmVersionId' => $version?->id,
|
||||
'filmWebsiteFrameUrl' => $film instanceof ContentElement && $version === null && $stills->websiteFile($film) !== null
|
||||
? route('content.website-frame', ['element' => $film])
|
||||
: null,
|
||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public function settings(): array
|
||||
{
|
||||
$choices = $this->textChoices();
|
||||
|
||||
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen']] : []) + [
|
||||
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen'], 'show_body' => self::SHOW] : []) + [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
@@ -180,7 +180,8 @@ public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'text_source' => ['Text der Karte', 'Welche Angabe aus der Redaktion die Karte zeigt. Vorgabe: Automatisch. Der gewählte Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Text.'],
|
||||
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer stumm ab, solange die Maus auf der Karte steht; am Handy mit Tippen auf das Bild, per Tastatur über die Schaltfläche am Bild. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
||||
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer als stumme Vorschau, solange die Maus auf der Karte steht; ein Klick oder Tipp auf das Bild oder die kleine Schaltfläche (auch per Tastatur) spielt ihn mit Ton. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
||||
'show_body' => ['Texte neben dem Bild', 'Ausblenden zeigt nur Bild und Video, ohne Titel, Text, Art, Zusatzangaben und Aktion. Für Hilfstechnik bleibt der Titel unsichtbar erhalten. Sinnvoll, wenn das Video allein erklärt. Vorgabe: anzeigen.'],
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
@@ -348,6 +349,7 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'actionLabel' => filled($data['action_label'] ?? null) ? (string) $data['action_label'] : $this->defaultActionLabel(),
|
||||
'note' => filled($data['note'] ?? null) ? (string) $data['note'] : null,
|
||||
'stacked' => $widget['variant'] === 'stacked',
|
||||
'bare' => $this->supportsClip() && $option('show_body', 'yes') === 'no',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public function checkoutFor(Order $order): array
|
||||
{
|
||||
$this->assertSandbox();
|
||||
$order->loadMissing('lines', 'user');
|
||||
$taxRate = $this->taxRate();
|
||||
|
||||
if ($order->status !== 'offen') {
|
||||
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
||||
@@ -58,10 +59,14 @@ public function checkoutFor(Order $order): array
|
||||
'product_data' => ['name' => filled($line->offer_name) ? (string) $line->offer_name : 'Lizenz'],
|
||||
],
|
||||
];
|
||||
|
||||
if ($taxRate !== null) {
|
||||
$params['line_items'][$index]['tax_rates'] = [$taxRate];
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->request()
|
||||
->withHeaders(['Idempotency-Key' => 'luf-order-'.$order->id.'-'.$attempt])
|
||||
->withHeaders(['Idempotency-Key' => $this->idempotencyKey($order, $attempt, $params)])
|
||||
->post('/v1/checkout/sessions', $params);
|
||||
|
||||
$this->assertOk($response, 'angelegt');
|
||||
@@ -94,6 +99,36 @@ public function assertSandbox(): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stripe bindet einen Schlüssel an die Parameter der ersten Anfrage und lehnt dieselbe Kennung mit anderen
|
||||
* Parametern ab. Der Schlüssel enthält deshalb einen Fingerabdruck der Parameter und die Minute: Ein
|
||||
* doppelter Klick bleibt wirkungslos, eine geänderte Anfrage oder ein Neuversuch nach einer Korrektur nicht.
|
||||
*
|
||||
* @param array<string, mixed> $params
|
||||
*/
|
||||
private function idempotencyKey(Order $order, int $attempt, array $params): string
|
||||
{
|
||||
$fingerprint = substr(sha1(json_encode([$params, now()->format('YmdHi')], JSON_THROW_ON_ERROR)), 0, 12);
|
||||
|
||||
return 'luf-order-'.$order->id.'-'.$attempt.'-'.$fingerprint;
|
||||
}
|
||||
|
||||
/** Konfigurierter Steuersatz oder null; eine ungültige ID wird abgewiesen, statt geraten zu werden. */
|
||||
private function taxRate(): ?string
|
||||
{
|
||||
$id = trim((string) config('services.stripe.tax_rate'));
|
||||
|
||||
if ($id === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! preg_match('/^txr_[A-Za-z0-9]+$/', $id)) {
|
||||
throw new DomainRuleException('Die Steuersatz-ID für Stripe ist ungültig (erwartet txr_...).');
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{id: string, url: string}|null
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
/**
|
||||
* Legt ein Bild aus einem Film als gewöhnliches Bild-Medium im Medienmanager ab (Medien- und Materialkarte).
|
||||
*
|
||||
* - Die Stelle kommt aus der bereitgestellten Fassung, bei einem Film ohne solche Fassung (zum Beispiel ein Teaser nur
|
||||
* mit Website-Datei) aus der Website-Datei (`teaser/`, Herkunft `frame:0@Sekunde`).
|
||||
* - Zwei Wege: das Vorschaubild des Films übernehmen oder eine Stelle (Sekunde) wählen. Beides ist eine
|
||||
* ausdrückliche Handlung der Redaktion; erst dadurch entsteht ein Bild, das für die Website freigegeben werden kann.
|
||||
* - Das Bild wird einmal gezogen und gespeichert (WebsiteIntake legt es an, die Warteschlange leitet es ab und gibt
|
||||
@@ -65,6 +67,23 @@ public function version(ContentElement $film): ?ContentElementVersion
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Website-Datei, aus der Stellen gezogen werden, wenn es keine bereitgestellte Fassung gibt (Film nur mit
|
||||
* Website-Datei). Sonst null.
|
||||
*/
|
||||
public function websiteFile(ContentElement $film): ?string
|
||||
{
|
||||
$path = $film->preview_path;
|
||||
|
||||
if ($this->version($film) instanceof ContentElementVersion
|
||||
|| ! is_string($path) || $path === '' || str_contains($path, '..') || ! str_starts_with($path, 'teaser/')
|
||||
|| ! Storage::disk('media_derived')->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/** Sekunde der Stelle, aus der das aktuelle Vorschaubild des Films stammt, sonst null. */
|
||||
public function thumbnailSecond(ContentElement $film): ?string
|
||||
{
|
||||
@@ -85,7 +104,11 @@ public function fromSecond(ContentElement $film, float $seconds, ?User $actor =
|
||||
$version = $this->version($film);
|
||||
|
||||
if (! $version instanceof ContentElementVersion) {
|
||||
throw new DomainRuleException('Der Film hat noch keine bereitgestellte Fassung.');
|
||||
if ($this->websiteFile($film) !== null) {
|
||||
return $this->fromWebsiteFrame($film, $seconds, $actor);
|
||||
}
|
||||
|
||||
throw new DomainRuleException('Der Film hat weder eine bereitgestellte Fassung noch eine Website-Datei.');
|
||||
}
|
||||
|
||||
return $this->fromFrame($film, $version, $seconds, $actor);
|
||||
@@ -158,6 +181,27 @@ private function fromFrame(ContentElement $film, ContentElementVersion $version,
|
||||
return $this->store($film, $key, $bytes, 'Fassung '.$version->number.', '.str_replace('.', ',', $second).' s', $actor);
|
||||
}
|
||||
|
||||
private function fromWebsiteFrame(ContentElement $film, float $seconds, ?User $actor): ContentElement
|
||||
{
|
||||
$second = $this->secondText($seconds);
|
||||
$key = 'frame:0@'.$second;
|
||||
$existing = $this->existing($film, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$bytes = $this->deriver->websiteFileJpeg($film, (float) $second, self::WIDTH);
|
||||
|
||||
if (! is_string($bytes)) {
|
||||
throw new DomainRuleException('Aus dieser Stelle der Website-Datei ließ sich kein Bild erzeugen.');
|
||||
}
|
||||
|
||||
return $this->store($film, $key, $bytes, 'Website-Datei, '.str_replace('.', ',', $second).' s', $actor);
|
||||
}
|
||||
|
||||
private function guard(ContentElement $film): void
|
||||
{
|
||||
$refusal = $this->refusal($film);
|
||||
|
||||
@@ -215,6 +215,15 @@ public function frameJpeg(ContentElementVersion $version, float $seconds, int $w
|
||||
* Einzelbild aus der Website-Datei eines Films (`teaser/`), für Medien ohne Inhaltsfassung.
|
||||
*/
|
||||
public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?string
|
||||
{
|
||||
return $this->websiteFileJpeg($element, $seconds, 640);
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild aus der Website-Datei in der gewünschten Breite, nie über die Breite der Datei hinaus (Standbild für
|
||||
* die Medienkarte, FilmStill).
|
||||
*/
|
||||
public function websiteFileJpeg(ContentElement $element, float $seconds, int $width): ?string
|
||||
{
|
||||
$file = $element->preview_path;
|
||||
|
||||
@@ -222,7 +231,7 @@ public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?str
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->jpegFromFile($file, $seconds, 640);
|
||||
return $this->jpegFromFile($file, $seconds, $width);
|
||||
}
|
||||
|
||||
private function jpegFromFile(string $file, float $seconds, int $width): ?string
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
'stripe' => [
|
||||
'secret' => env('STRIPE_SECRET'),
|
||||
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
|
||||
// Optional: ID eines in Stripe angelegten Steuersatzes (txr_...), der jeder Position mitgegeben wird.
|
||||
// Er muss im Preis enthalten (inklusiv) sein, sonst weicht der gezahlte Betrag von der Bestellung ab.
|
||||
'tax_rate' => env('STRIPE_TAX_RATE_ID'),
|
||||
'api_base' => env('STRIPE_API_BASE', 'https://api.stripe.com'),
|
||||
],
|
||||
|
||||
|
||||
@@ -32,5 +32,6 @@ MAIL_FROM_NAME="${APP_NAME}"
|
||||
PAYMENT_DRIVER=test
|
||||
# STRIPE_SECRET=sk_test_... (Entwickler > API-Schlüssel, Testmodus)
|
||||
# STRIPE_WEBHOOK_SECRET=whsec_... (Entwickler > Webhooks > Endpunkt > Signiergeheimnis)
|
||||
# STRIPE_TAX_RATE_ID=txr_... (optional: in Stripe angelegter, im Preis enthaltener Steuersatz)
|
||||
|
||||
# Medienpfade setzt Compose auf den Host-Mount (/srv/luf/<env>/media/...). Hier nichts eintragen.
|
||||
@@ -314,6 +314,8 @@ ## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39)
|
||||
|
||||
**Video im Einstieg (Hero, Variante `photo_split`).** Optional `refs.video`: ein Film aus dem Medienmanager (Auswahl über `HeroVideo`, geprüft: Film, nicht archiviert, nicht gesperrt, keine Traineranleitung). Gespielt wird der freigegebene Clip nach der Regel der Karte (`CardClip`: Trailer, Vorschauclip, sonst die freigegebene Website-Datei des Films). Das Video liegt stumm auf der Fläche des Fotos, startet nach dem Laden von selbst (nicht bei „reduzierte Bewegung“, Datensparmodus, 2G), hat eine Schaltfläche zum Anhalten und fällt bei Fehlern auf das Foto zurück; `resources/js/hero-video.js`. Die Markenfläche zeigt kein Video. Entscheidung: ADR-43 (Nachtrag).
|
||||
|
||||
**Karte ohne Texte (Medien-, Programm- und Modulkarte).** Einstellung `settings.show_body` (`yes` Vorgabe, `no`; Darstellung → „Texte neben dem Bild“). Bei `no` zeigt die Karte nur Bild oder Video: ohne Titel, Text, Art, Zusatzangaben, Aktion und Marke im Bild, immer Bild über dem (leeren) Textbereich. Der Titel bleibt als `visually-hidden`-Überschrift für Hilfstechnik, ein Trailer läuft weiter, die Redaktionsvorschau zeigt ihre Hinweise weiter. Die Themenkarte hat die Einstellung nicht (sie bliebe leer).
|
||||
|
||||
**Trailer auf der Karte (Medien-, Programm- und Modulkarte).** Einstellung `settings.clip` (`yes` Vorgabe, `no`). Der Clip ist der Trailer des Objekts (Präsentationsrolle „Trailer“, sonst „Vorschauclip“, bei einem Film ersatzweise sein freigegebener Teaser), nur wenn er für die Website freigegeben ist (`CardClip`). Er liegt über dem Kartenbild: Beim Überfahren mit der Maus läuft eine stumme Vorschau in Schleife; ein Klick oder Tipp (Handy) auf das Bild oder die kleine Schaltfläche (auch per Tastatur) spielt ihn mit Ton ab; `resources/js/card-clip.js`. Ohne Freigabe bleibt das Bild; die Redaktionsvorschau nennt den Grund. Entscheidung: ADR-43.
|
||||
|
||||
**Text der Karte.** Einstellung `settings.text_source` (`auto` Vorgabe, `teaser`, `summary`, `description`; an der Programm- und Modulkarte zusätzlich `goal`, das Lernziel der Fassung). `auto` entspricht dem bisherigen Verhalten je Karte (Medien: Kurzbeschreibung, sonst Teaser; Programm und Modul: Teaser, sonst Kurzbeschreibung, sonst Lernziel); die Themenkarte hat nur einen Text und keine Wahl. Eine ausdrückliche Wahl ersetzt nicht still durch ein anderes Feld. Die ausführliche Beschreibung erscheint nur auf diese Wahl (öffentlich, sofern die Karte öffentlich ist). Der eigene Text der Karte (`data.summary`) hat Vorrang.
|
||||
|
||||
@@ -169,6 +169,7 @@ ### Bild aus dem Film
|
||||
|
||||
`FilmStill` zieht das Einzelbild **einmal** und legt es über `WebsiteIntake` als gewöhnliches Bild-Medium (`output_class = bild`) im Medienmanager ab. Die Warteschlange leitet es ab und gibt genau diese Ableitung frei, wie bei jedem Upload aus dem CMS. Die Karte speichert die Kennung dieses Bildes in `refs.image`.
|
||||
|
||||
- **Film nur mit Website-Datei (22.11.2026):** Hat ein Film keine bereitgestellte Fassung, aber eine Website-Datei (`teaser/…`, zum Beispiel ein Teaser), kommt die Stelle aus dieser Datei (Regler und Vorschau über `content.website-frame`, Herkunft `frame:0@Sekunde`, höchstens die Breite der Datei). Vorher blieb der Regler dafür aus („keine bereitgestellte Fassung“).
|
||||
- **Kein Neuziehen:** Seitenaufrufe lesen nur die gespeicherte Datei; `ffmpeg` läuft nur beim Übernehmen und in der Vorschau des Dialogs (Route `editorial.frame`, nur angemeldete Redaktion). Test: `FilmStillTest` zählt die Extraktionen.
|
||||
- **Einmal je Stelle:** `film_still_sources` (additive Tabelle) ordnet Film, Quelle (`frame:{Fassung}@{Sekunde}` oder `file:{SHA-256}`) und Bild zu. Dieselbe Stelle, auch über „Vorschaubild übernehmen“ eines Filmbilds aus derselben Stelle, ergibt dasselbe Medium. Ein archiviertes oder bei der Verarbeitung gescheitertes Bild wird nicht wiederverwendet; die Stelle lässt sich dann neu übernehmen.
|
||||
- **Wiederverwendung ehrlich melden:** Wird ein schon übernommenes Bild gewählt, sagt die Meldung, wie es steht (bereits freigegeben, wird verarbeitet oder Website-Freigabe zurückgenommen). Eine zurückgenommene Freigabe bleibt zurückgenommen; das Bild erscheint öffentlich erst nach erneuter Freigabe im Medienmanager (Reiter „Website“).
|
||||
|
||||
@@ -43,8 +43,11 @@ ## Stripe-Sandbox (nur Test, Etappe 1)
|
||||
PAYMENT_DRIVER=stripe
|
||||
STRIPE_SECRET=sk_test_...
|
||||
STRIPE_WEBHOOK_SECRET=whsec_...
|
||||
STRIPE_TAX_RATE_ID=txr_...
|
||||
```
|
||||
|
||||
`STRIPE_TAX_RATE_ID` ist optional. Verlangt Stripe für die Positionen eine Steuerangabe (Fehler „the product tax code is missing“), wird der in Stripe angelegte Steuersatz jeder Position mitgegeben. Er muss **im Preis enthalten (inklusiv)** sein: Die Bestellsumme ist der Bruttobetrag, und bei einem aufschlagenden Satz weicht der gezahlte Betrag ab, sodass die Zahlung als `zu_pruefen` festgehalten wird und nichts freischaltet. Welcher Satz gilt, entscheiden Steuer und Finance, nicht die Anwendung.
|
||||
|
||||
4. In Gitea den letzten Lauf von „Deploy Test“ erneut starten (siehe „Env-Datei ändern“). `docker exec luf-test-app-1 printenv PAYMENT_DRIVER` muss `stripe` zeigen.
|
||||
5. Testkauf mit der Stripe-Testkarte `4242 4242 4242 4242` (beliebiges künftiges Ablaufdatum, beliebige Prüfziffer). In Stripe unter Entwickler > Webhooks > Endpunkt > Ereignisse ist jede Zustellung samt Antwortcode zu sehen.
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ ## 1. Inhalt (Stand 21.11.2026 abends: 22 Commits seit `main`)
|
||||
| Programm- und Modulkarte | Text der Karte wählen (zusätzlich Lernziel); Vorschaubild als Website-Bild übernehmen | Claude |
|
||||
| Trailer auf Karten | Medien-, Programm- und Modulkarte spielen den für die Website freigegebenen Trailer (Rolle Trailer, sonst Vorschauclip, bei Filmen ersatzweise der eigene Teaser) beim Überfahren mit der Maus als stumme Vorschau und per Klick oder Tipp mit Ton ab (kleine Symbolschaltfläche); je Karte abschaltbar; die Medienroute beantwortet Bereichsabrufe (ADR-43). Auf luf-test mit einem echten Clip geprüft. Keine Migration | Claude |
|
||||
| Medienkarte: Film nur mit Website-Datei | Ein Medium ohne Fassung (z. B. Teaser) ist auf der Medienkarte wählbar und erscheint öffentlich, sobald die Datei für die Website freigegeben ist (ohne Programmseite, ohne Aktion). Keine Migration | Claude |
|
||||
| Karte ohne Texte | Medien- und Programmkarte: Einstellung „Texte neben dem Bild“ (Ausblenden) zeigt nur Bild oder Video; der Titel bleibt für Hilfstechnik. Keine Migration | Claude |
|
||||
| Hero mit Video | Der Einstieg (Variante Foto mit Textfläche) spielt auf Wunsch ein freigegebenes Video stumm auf der Fläche des Fotos ab, mit Schaltfläche zum Anhalten; Foto als Rückfall (ADR-43 Nachtrag). Keine Migration | Claude |
|
||||
| Website-Datei eines Films | Ablage der Datei eines eigenständigen Präsentationsmediums über die Warteschlange, nachträgliches Hochladen am Medium (Behebung: der Web-Prozess darf `derived/` nicht schreiben) | Lars (anderer Rechner) |
|
||||
| Medienmanager | „Medium löschen“ erreicht Standbilder und übernommene CMS-Bilder (Fremdschlüssel gelockert) | Claude |
|
||||
|
||||
@@ -80,6 +80,12 @@ .lf-pc--contain .lf-pc__image {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Nur Bild oder Video (Einstellung „Texte neben dem Bild“ ausgeblendet): ringsum gleicher Rand, kein Textbereich. */
|
||||
.lf-pc--bare .lf-pc__visual,
|
||||
.lf-pc--bare .lf-pc__panel { margin-block-end: 10px; }
|
||||
|
||||
.lf-pc--bare .lf-pc__body { padding: 0; gap: 0; }
|
||||
|
||||
.lf-pc__badge {
|
||||
position: absolute;
|
||||
inset: 12px auto auto 12px;
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
@php
|
||||
$pfad = $getStatePath();
|
||||
$ziel = preg_replace('/[^.]+$/', 'image', $pfad);
|
||||
$framePfad = $filmVersionId !== null ? route('editorial.frame', ['version' => $filmVersionId]) : null;
|
||||
$framePfad = $filmVersionId !== null ? route('editorial.frame', ['version' => $filmVersionId]) : ($filmWebsiteFrameUrl ?? null);
|
||||
$ausWebsiteDatei = $filmVersionId === null && ($filmWebsiteFrameUrl ?? null) !== null;
|
||||
@endphp
|
||||
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
|
||||
<div class="luf-filmbild"
|
||||
@@ -16,7 +17,7 @@
|
||||
show() { if (this.second !== '' && ! isNaN(Number(this.second)) && Number(this.second) >= 0) { this.shown = this.second; } } }">
|
||||
<p class="luf-filmbild-lead">
|
||||
Aus dem Film „{{ $filmTitle }}“ ein Bild für die Website übernehmen. Das Bild wird einmal gespeichert und im
|
||||
Medienmanager als Bild angelegt. Der Film selbst wird nicht veröffentlicht; die Karte spielt nichts ab.
|
||||
Medienmanager als Bild angelegt. Der Film selbst wird nicht veröffentlicht.@if ($ausWebsiteDatei) Die Stelle kommt aus der Website-Datei des Films.@endif
|
||||
</p>
|
||||
@if ($framePfad !== null)
|
||||
<div class="luf-filmbild-regler">
|
||||
@@ -34,7 +35,7 @@
|
||||
</x-filament::button>
|
||||
</div>
|
||||
@else
|
||||
<p class="luf-filmbild-lead">Der Film hat noch keine bereitgestellte Fassung; eine Stelle lässt sich erst danach wählen.</p>
|
||||
<p class="luf-filmbild-lead">Der Film hat weder eine bereitgestellte Fassung noch eine Website-Datei; eine Stelle lässt sich erst danach wählen.</p>
|
||||
@endif
|
||||
@if ($filmHasThumbnail)
|
||||
<div class="luf-filmbild-aktuell">
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
öffentlich markiert. Es hat keine Freigabe für die Website und wird öffentlich nie ausgegeben.
|
||||
3. Tafel nach Fachobjekt: Programm/Modul (Navy), Film (Filmtafel), Material (Materialsymbol); Thema ohne Bildbereich.
|
||||
Hinweise auf fehlende Inhalte stehen nur in der Redaktionsvorschau, öffentlich nie.
|
||||
Texte ausgeblendet ($bare, Einstellung „Texte neben dem Bild“): nur Bildbereich; der Titel bleibt unsichtbar für
|
||||
Hilfstechnik, Hinweise für die Redaktion weiter in der Vorschau.
|
||||
|
||||
Trailer: Ist für das Objekt ein für die Website freigegebener Clip da ($clip['url'], CardClip), liegt er stumm und
|
||||
unsichtbar über dem Bildbereich und startet beim Überfahren mit der Maus, am Handy mit Tippen auf das Bild, per
|
||||
@@ -43,7 +45,8 @@
|
||||
'lf-pc--'.$cardStyle,
|
||||
'lf-pc--'.$format,
|
||||
'lf-pc--'.$fit,
|
||||
'lf-pc--stacked' => $stacked,
|
||||
'lf-pc--stacked' => $stacked || ! empty($bare),
|
||||
'lf-pc--bare' => ! empty($bare),
|
||||
'lf-pc--without-visual' => $imageUrl === null && $libraryImage === null && $panel === null,
|
||||
'lf-pc--internal' => ! $subject->public,
|
||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||
@@ -51,7 +54,7 @@
|
||||
<div class="lf-pc__visual" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
||||
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||
@include('widgets.partials.card-clip')
|
||||
@if ($show['kind'] && $subject->badge !== null)
|
||||
@if ($show['kind'] && $subject->badge !== null && empty($bare))
|
||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||
@endif
|
||||
@if ($libraryImage !== null)
|
||||
@@ -78,21 +81,21 @@
|
||||
</div>
|
||||
@endif
|
||||
<div class="lf-pc__body">
|
||||
@if ($show['kind'] && $subject->kind !== '')
|
||||
@if (empty($bare) && $show['kind'] && $subject->kind !== '')
|
||||
<p class="lf-pc__kind">{{ $subject->kind }}</p>
|
||||
@endif
|
||||
<{{ $headingTag }} class="lf-pc__title">{{ $subject->title }}</{{ $headingTag }}>
|
||||
@if ($show['summary'] && filled($subject->summary))
|
||||
<{{ $headingTag }} @class(['lf-pc__title', 'visually-hidden' => ! empty($bare)])>{{ $subject->title }}</{{ $headingTag }}>
|
||||
@if (empty($bare) && $show['summary'] && filled($subject->summary))
|
||||
<p class="lf-pc__summary">{{ $subject->summary }}</p>
|
||||
@endif
|
||||
@if ($meta !== [])
|
||||
@if (empty($bare) && $meta !== [])
|
||||
<ul class="lf-pc__meta" aria-label="Weitere Angaben">
|
||||
@foreach ($meta as $item)
|
||||
<li>{{ $item }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@if ($action !== null || $note !== null)
|
||||
@if (empty($bare) && ($action !== null || $note !== null))
|
||||
<div class="lf-pc__footer">
|
||||
@if ($note !== null)
|
||||
<p class="lf-pc__note">{{ $note }}</p>
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\PresentationAssignment;
|
||||
use App\Domain\Catalog\PresentationRole;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Medien- und Programmkarte ohne Texte: Die Einstellung „Texte neben dem Bild“ (show_body = no) zeigt nur Bild oder
|
||||
* Video, ohne Titel, Text, Art, Zusatzangaben und Aktion. Der Titel bleibt für Hilfstechnik unsichtbar erhalten, ein
|
||||
* Trailer läuft weiter.
|
||||
*/
|
||||
class CmsCardWithoutTextTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
}
|
||||
|
||||
public function test_the_default_still_shows_all_texts(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$this->publish('/mit-text', $this->card($film, []));
|
||||
|
||||
$html = $this->card_html($this->get('/mit-text')->assertOk()->getContent());
|
||||
|
||||
$this->assertStringContainsString('Eine Pause, die stark macht', $html);
|
||||
$this->assertStringContainsString('KURZ-TEXT', $html);
|
||||
$this->assertStringContainsString('lf-pc__cta', $html);
|
||||
$this->assertStringContainsString('lf-pc__meta', $html);
|
||||
$this->assertStringNotContainsString('lf-pc--bare', $html);
|
||||
}
|
||||
|
||||
public function test_without_texts_only_the_picture_remains_and_the_title_stays_for_assistive_technology(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$this->publish('/ohne-text', $this->card($film, ['show_body' => 'no']));
|
||||
|
||||
$html = $this->card_html($this->get('/ohne-text')->assertOk()->getContent());
|
||||
|
||||
$this->assertStringContainsString('lf-pc--bare', $html);
|
||||
$this->assertStringNotContainsString('KURZ-TEXT', $html);
|
||||
$this->assertStringNotContainsString('lf-pc__cta', $html, 'Keine Aktion.');
|
||||
$this->assertStringNotContainsString('lf-pc__meta', $html, 'Keine Zusatzangaben.');
|
||||
$this->assertStringNotContainsString('lf-pc__kind', $html, 'Keine Art.');
|
||||
$this->assertStringNotContainsString('lf-pc__badge', $html, 'Keine Marke im Bild.');
|
||||
$this->assertStringContainsString('class="lf-pc__title visually-hidden"', $html);
|
||||
$this->assertStringContainsString('Eine Pause, die stark macht', $html, 'Der Titel bleibt für Hilfstechnik erhalten.');
|
||||
}
|
||||
|
||||
public function test_the_trailer_still_plays_on_a_card_without_texts(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$trailer = $this->clip('Trailer Denkpause');
|
||||
PresentationAssignment::query()->create([
|
||||
'subject_type' => $film->getMorphClass(),
|
||||
'subject_id' => $film->getKey(),
|
||||
'content_element_id' => $trailer->id,
|
||||
'presentation_role_id' => PresentationRole::query()->where('slug', 'trailer')->value('id'),
|
||||
'position' => 1,
|
||||
]);
|
||||
app(WebsiteRelease::class)->release($trailer->fresh());
|
||||
foreach ([WebsiteImage::class, CardClip::class, WebsiteMedia::class] as $class) {
|
||||
$this->app->forgetInstance($class);
|
||||
}
|
||||
$this->publish('/ohne-text-trailer', $this->card($film, ['show_body' => 'no']));
|
||||
|
||||
$html = $this->card_html($this->get('/ohne-text-trailer')->assertOk()->getContent());
|
||||
|
||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $html);
|
||||
$this->assertStringContainsString('aria-label="Trailer abspielen: Trailer Denkpause"', $html);
|
||||
$this->assertStringNotContainsString('KURZ-TEXT', $html);
|
||||
}
|
||||
|
||||
public function test_only_cards_with_a_picture_offer_the_choice_and_it_is_validated(): void
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
|
||||
$this->assertSame(['yes', 'no'], array_keys($registry->get('media_card')->settingOptions()['show_body']));
|
||||
$this->assertSame(['yes', 'no'], array_keys($registry->get('program_card')->settingOptions()['show_body']));
|
||||
$this->assertArrayNotHasKey('show_body', $registry->get('topic_card')->settingOptions(), 'Eine Themenkarte ohne Bild bliebe leer.');
|
||||
|
||||
$film = $this->publicFilm();
|
||||
|
||||
try {
|
||||
$registry->normalize($this->card($film, ['show_body' => 'vielleicht'])[0]['slots']);
|
||||
$this->fail('Eine unbekannte Wahl wurde angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('blocks.0.settings.show_body', $exception->errors());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_the_preview_keeps_the_editorial_notes_on_a_card_without_texts(): void
|
||||
{
|
||||
$film = $this->publicFilm();
|
||||
$revision = $this->publish('/ohne-text-vorschau', $this->card($film, ['show_body' => 'no']));
|
||||
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('lf-pc--bare', $preview);
|
||||
$this->assertStringNotContainsString('lf-pc__cta', $preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $settings
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function card(ContentElement $film, array $settings): array
|
||||
{
|
||||
return [['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => [], 'refs' => ['element' => $film->id]],
|
||||
]]];
|
||||
}
|
||||
|
||||
private function card_html(string $html): string
|
||||
{
|
||||
preg_match('#<article class="lf-pc .*?</article>#s', $html, $match);
|
||||
|
||||
return $match[0] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
private function publish(string $path, array $sections): PageRevision
|
||||
{
|
||||
$page = Page::query()->create(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$revision = $service->saveRevision($page, $sections, null, null, null);
|
||||
$service->publish($page, $revision);
|
||||
|
||||
return $revision;
|
||||
}
|
||||
|
||||
private function publicFilm(): ContentElement
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'KURZ-TEXT']);
|
||||
$film->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'unterrichtsfilm')->value('id')])->save();
|
||||
$version = $content->publishElementVersion($film, 'Film');
|
||||
$composition = $content->createComposition('Programm Denkpause');
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->save();
|
||||
$shown = $content->publishComposition($composition, [['role' => 'Film', 'target' => $version]]);
|
||||
app(CompositionDisplayRelease::class)->release($shown, User::factory()->create());
|
||||
|
||||
return $film->refresh();
|
||||
}
|
||||
|
||||
private function clip(string $title): ContentElement
|
||||
{
|
||||
$path = 'inhalte/'.md5($title).'.mp4';
|
||||
Storage::disk('cms_incoming')->put($path, '0123456789abcdefghij');
|
||||
$element = app(ContentService::class)->createElement('film', 'film', $title);
|
||||
$element->display_title = $title;
|
||||
$element->save();
|
||||
app(PresentationFile::class)->store($element, $path);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Media\FilmStill;
|
||||
use App\Domain\Media\FilmStillSource;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Bild aus einem Film nur mit Website-Datei (zum Beispiel ein Teaser) für die Medienkarte: Die Stelle kommt aus der
|
||||
* Website-Datei, weil es keine bereitgestellte Fassung gibt. Die Bildextraktion (ffmpeg) ist durch einen Stub ersetzt.
|
||||
*/
|
||||
class FilmStillWebsiteFileTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/** @var object{calls: list<array{second: float, width: int}>, fail: bool} */
|
||||
private object $extractor;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
|
||||
$this->extractor = new class($this->jpeg()) extends ThumbnailDeriver
|
||||
{
|
||||
/** @var list<array{second: float, width: int}> */
|
||||
public array $calls = [];
|
||||
|
||||
public bool $fail = false;
|
||||
|
||||
public function __construct(private readonly string $jpeg) {}
|
||||
|
||||
public function websiteFileJpeg(ContentElement $element, float $seconds, int $width): ?string
|
||||
{
|
||||
$this->calls[] = ['second' => $seconds, 'width' => $width];
|
||||
|
||||
return $this->fail ? null : $this->jpeg;
|
||||
}
|
||||
};
|
||||
$this->app->instance(ThumbnailDeriver::class, $this->extractor);
|
||||
}
|
||||
|
||||
public function test_a_frame_of_the_website_file_becomes_one_image_medium(): void
|
||||
{
|
||||
$film = $this->teaser();
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
|
||||
$still = app(FilmStill::class)->fromSecond($film, 7.5, $editor)->refresh();
|
||||
|
||||
$this->assertSame('bild', $still->output_class);
|
||||
$this->assertSame('Standbild: Teaser Denkpause (Website-Datei, 7,5 s)', $still->display_title);
|
||||
$this->assertSame('Szene aus dem Film „Teaser Denkpause“', $still->website_alt);
|
||||
$this->assertSame(0, $still->versions()->count(), 'Es entsteht keine Inhaltsfassung.');
|
||||
$this->assertSame([['second' => 7.5, 'width' => FilmStill::WIDTH]], $this->extractor->calls);
|
||||
$this->assertSame('frame:0@7.5', FilmStillSource::query()->where('film_element_id', $film->id)->value('source_key'));
|
||||
$this->assertSame($still->id, FilmStillSource::query()->value('still_element_id'));
|
||||
}
|
||||
|
||||
public function test_the_same_frame_of_the_website_file_is_never_extracted_twice(): void
|
||||
{
|
||||
$film = $this->teaser();
|
||||
|
||||
$first = app(FilmStill::class)->fromSecond($film, 3);
|
||||
$again = app(FilmStill::class)->fromSecond($film, 3.0);
|
||||
|
||||
$this->assertSame($first->id, $again->id);
|
||||
$this->assertCount(1, $this->extractor->calls);
|
||||
}
|
||||
|
||||
public function test_a_film_with_neither_a_version_nor_a_website_file_is_refused(): void
|
||||
{
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Leer');
|
||||
|
||||
$this->assertNull(app(FilmStill::class)->websiteFile($film));
|
||||
$this->expectException(DomainRuleException::class);
|
||||
$this->expectExceptionMessage('weder eine bereitgestellte Fassung noch eine Website-Datei');
|
||||
|
||||
app(FilmStill::class)->fromSecond($film, 3);
|
||||
}
|
||||
|
||||
public function test_a_frame_that_cannot_be_extracted_creates_nothing(): void
|
||||
{
|
||||
$film = $this->teaser();
|
||||
$this->extractor->fail = true;
|
||||
$before = ContentElement::query()->count();
|
||||
|
||||
try {
|
||||
app(FilmStill::class)->fromSecond($film, 3);
|
||||
$this->fail('Ohne Bild darf nichts angelegt werden.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('Website-Datei', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame($before, ContentElement::query()->count());
|
||||
}
|
||||
|
||||
public function test_the_editor_adopts_a_frame_of_the_website_file_into_the_card_image(): void
|
||||
{
|
||||
$film = $this->teaser();
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
$page = Page::query()->create(['path' => '/teaser-bild']);
|
||||
app(PageService::class)->saveRevision($page, [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['element' => $film->id]]]],
|
||||
], null, null, null);
|
||||
|
||||
$component = Livewire::actingAs($editor, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||
$component->call('adoptFilmFrame', 'data.ziel.image', $film->id, '7.5');
|
||||
|
||||
$still = ContentElement::query()->where('output_class', 'bild')->latest('id')->firstOrFail();
|
||||
$this->assertSame($still->id, $component->get('data.ziel.image'));
|
||||
$component->assertNotified('Im Medienmanager angelegt: „Standbild: Teaser Denkpause (Website-Datei, 7,5 s)“');
|
||||
}
|
||||
|
||||
public function test_the_card_field_offers_the_slider_with_the_website_file_for_such_a_film(): void
|
||||
{
|
||||
$film = $this->teaser();
|
||||
$widget = app(WidgetRegistry::class)->get('media_card');
|
||||
$data = (new \ReflectionMethod($widget, 'filmFieldData'))->invoke($widget, $film);
|
||||
|
||||
$this->assertNull($data['filmVersionId']);
|
||||
$this->assertSame(route('content.website-frame', ['element' => $film]), $data['filmWebsiteFrameUrl'], 'Der Regler zeigt Stellen der Website-Datei.');
|
||||
$this->assertSame('0', $data['filmStartSecond']);
|
||||
}
|
||||
|
||||
private function teaser(): ContentElement
|
||||
{
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Teaser Denkpause');
|
||||
$film->forceFill(['preview_path' => 'teaser/'.$film->id.'/datei.mp4'])->save();
|
||||
Storage::disk('media_derived')->put($film->preview_path, 'x');
|
||||
|
||||
return $film->fresh();
|
||||
}
|
||||
|
||||
private function jpeg(): string
|
||||
{
|
||||
$image = imagecreatetruecolor(1600, 900);
|
||||
imagefill($image, 0, 0, imagecolorallocate($image, 40, 120, 90));
|
||||
ob_start();
|
||||
imagejpeg($image);
|
||||
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public function test_paying_creates_a_checkout_session_with_the_order_amounts_an
|
||||
|
||||
return $request->url() === 'https://stripe.test/v1/checkout/sessions'
|
||||
&& $request->hasHeader('Authorization', 'Bearer sk_test_nur_fuer_tests')
|
||||
&& $request->hasHeader('Idempotency-Key', 'luf-order-'.$order->id.'-1')
|
||||
&& preg_match('/^luf-order-'.$order->id.'-1-[0-9a-f]{12}$/', (string) ($request->header('Idempotency-Key')[0] ?? '')) === 1
|
||||
&& $body['mode'] === 'payment'
|
||||
&& $body['client_reference_id'] === (string) $order->id
|
||||
&& $body['metadata']['order_id'] === (string) $order->id
|
||||
@@ -85,6 +85,55 @@ public function test_paying_creates_a_checkout_session_with_the_order_amounts_an
|
||||
$this->assertSame('offen', $order->fresh()->status, 'Bezahlt wird erst durch die signierte Meldung.');
|
||||
}
|
||||
|
||||
public function test_a_configured_tax_rate_is_sent_with_every_line_and_otherwise_none(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte(), $this->privateGrenzen()]);
|
||||
Http::fake(['stripe.test/v1/checkout/sessions' => Http::response(['id' => 'cs_test_s', 'url' => 'https://checkout.stripe.test/s'])]);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect();
|
||||
Http::assertSent(function (HttpRequest $request): bool {
|
||||
parse_str($request->body(), $body);
|
||||
|
||||
return ! isset($body['line_items'][0]['tax_rates']) && ! isset($body['line_items'][1]['tax_rates']);
|
||||
});
|
||||
|
||||
$order->payments()->delete();
|
||||
config(['services.stripe.tax_rate' => 'txr_Testsatz123']);
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect();
|
||||
Http::assertSent(function (HttpRequest $request): bool {
|
||||
parse_str($request->body(), $body);
|
||||
|
||||
return ($body['line_items'][0]['tax_rates'] ?? null) === ['txr_Testsatz123']
|
||||
&& ($body['line_items'][1]['tax_rates'] ?? null) === ['txr_Testsatz123'];
|
||||
});
|
||||
}
|
||||
|
||||
public function test_changed_parameters_never_reuse_an_idempotency_key(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||
Http::fake(['stripe.test/v1/checkout/sessions' => Http::response(['id' => 'cs_test_k', 'url' => 'https://checkout.stripe.test/k'])]);
|
||||
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect();
|
||||
$order->payments()->delete();
|
||||
config(['services.stripe.tax_rate' => 'txr_Testsatz123']);
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect();
|
||||
|
||||
$keys = Http::recorded()->map(fn (array $pair): string => (string) $pair[0]->header('Idempotency-Key')[0])->values();
|
||||
$this->assertCount(2, $keys);
|
||||
$this->assertNotSame($keys[0], $keys[1], 'Geänderte Parameter brauchen einen anderen Schlüssel als dieselbe Bestellung zuvor.');
|
||||
}
|
||||
|
||||
public function test_an_invalid_tax_rate_id_is_refused_before_any_call(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||
config(['services.stripe.tax_rate' => 'txcd_99999999']);
|
||||
Http::fake();
|
||||
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))
|
||||
->assertSessionHasErrors(['payment' => 'Die Steuersatz-ID für Stripe ist ungültig (erwartet txr_...).']);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_an_open_session_is_reused(): void
|
||||
{
|
||||
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||
@@ -105,7 +154,7 @@ public function test_an_expired_session_is_replaced_by_a_new_one(): void
|
||||
'stripe.test/v1/checkout/sessions' => Http::response(['id' => 'cs_test_neu', 'url' => 'https://checkout.stripe.test/neu']),
|
||||
]);
|
||||
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect('https://checkout.stripe.test/neu');
|
||||
Http::assertSent(fn (HttpRequest $request): bool => $request->hasHeader('Idempotency-Key', 'luf-order-'.$order->id.'-2'));
|
||||
Http::assertSent(fn (HttpRequest $request): bool => preg_match('/^luf-order-'.$order->id.'-2-[0-9a-f]{12}$/', (string) ($request->header('Idempotency-Key')[0] ?? '')) === 1);
|
||||
}
|
||||
|
||||
public function test_only_the_buyer_pays_and_only_an_open_order(): void
|
||||
|
||||
Reference in new issue
Block a user