Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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,6 +59,10 @@ 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()
|
||||
@@ -94,6 +99,22 @@ public function assertSandbox(): void
|
||||
}
|
||||
}
|
||||
|
||||
/** 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.
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,40 @@ 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_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()]);
|
||||
|
||||
Reference in new issue
Block a user