Add feature tests for shop functionality and organization purchases
- Implement OfferOptionAdminTest to validate offer option management, including price display, activation, and cancellation. - Create OrganizationPurchaseTest to ensure correct handling of organization purchases, including access control and order processing. - Add ShopProductPageTest to verify shop product listings, search functionality, and product page details. - Introduce BuildsShop trait for seeding test data related to shop functionality. - Implement MoneyTest to validate money parsing and formatting, ensuring correct handling of euro amounts.
This commit is contained in:
1 parent
6c8bbee363
commit
4e0760db1e
106 files changed
+4068
-76
No files matched your search
@@ -0,0 +1,114 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', 'Warenkorb')
|
||||
|
||||
@section('content')
|
||||
<h1>Warenkorb</h1>
|
||||
|
||||
@if ($errors->any())
|
||||
<p class="errors" role="alert">{{ $errors->first() }}</p>
|
||||
@endif
|
||||
|
||||
@if ($review->lines === [])
|
||||
<div class="empty">
|
||||
<h2>Dein Warenkorb ist leer</h2>
|
||||
<p>Wähle auf einer Produktseite eine Lizenzoption und lege sie in den Warenkorb.</p>
|
||||
<p><a class="button" href="{{ route('shop') }}">Zum Shop</a></p>
|
||||
</div>
|
||||
@else
|
||||
@if ($holders->count() > 1)
|
||||
<form class="shop-holder" method="get" action="{{ route('cart') }}">
|
||||
<label for="bestellen_als">Bestellen als</label>
|
||||
<select id="bestellen_als" name="bestellen_als">
|
||||
@foreach ($holders as $holder)
|
||||
<option value="{{ $holder->id }}" @selected($review->holder?->id === $holder->id)>{{ $holder->display_name }} ({{ $holder->type->value === 'person' ? 'Privatperson' : 'Verein oder Organisation' }})</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<button class="button button-secondary" type="submit">Übernehmen</button>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
<ul class="shop-lines">
|
||||
@foreach ($review->lines as $line)
|
||||
<li @class(['shop-line', 'is-owned' => $line->state === 'bereits_erworben', 'is-blocked' => $line->blocks()])>
|
||||
<div class="shop-line-main">
|
||||
<h2>{{ $line->title() }}</h2>
|
||||
<p class="shop-line-option">{{ $line->offer->optionName() }}</p>
|
||||
|
||||
@if ($line->state === 'bereits_erworben')
|
||||
<p class="shop-badge shop-badge-owned">Bereits erworben · Wird nicht mitbestellt</p>
|
||||
@if ($review->holder?->type->value === 'organisation')
|
||||
<p class="shop-note">Dieser Umfang mit denselben Nutzungsrechten gehört dem Verein bereits. Herunterladen kann nur das Konto, das die Lizenz bestellt hat. Die Position geht nicht in die Summe ein.</p>
|
||||
@else
|
||||
<p class="shop-note">Dieser Umfang mit denselben Nutzungsrechten liegt bereits in der Bibliothek. Die Position geht nicht in die Summe ein.</p>
|
||||
@endif
|
||||
@elseif ($line->state === 'zurueckgezogen')
|
||||
<p class="shop-badge shop-badge-blocked">Nicht mehr erhältlich</p>
|
||||
<p class="shop-note">{{ $line->note }}</p>
|
||||
@elseif ($line->state === 'falscher_inhaber')
|
||||
<p class="shop-badge shop-badge-blocked">Passt nicht zum Lizenzinhaber</p>
|
||||
<p class="shop-note">{{ $line->note }}</p>
|
||||
@elseif ($line->state === 'preis_geaendert')
|
||||
<p class="shop-badge shop-badge-changed">Preis geändert</p>
|
||||
<p class="shop-note">Bisher {{ \App\Domain\Commerce\Money::format($line->seenPriceCents) }}, jetzt {{ \App\Domain\Commerce\Money::format($line->currentPriceCents) }}. Du kannst zum neuen Preis bestellen oder die Position entfernen.</p>
|
||||
@elseif ($line->state === 'bedingungen_geaendert')
|
||||
<p class="shop-badge shop-badge-changed">Bedingungen aktualisiert</p>
|
||||
<p class="shop-note">{{ $line->note }}</p>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="shop-line-side">
|
||||
@if ($line->currentPriceCents !== null)
|
||||
<p @class(['shop-price', 'is-struck' => $line->state === 'bereits_erworben'])>
|
||||
@if ($line->state === 'preis_geaendert')
|
||||
<s class="shop-price-old"><span class="sr-only">Bisheriger Preis: </span>{{ \App\Domain\Commerce\Money::format($line->seenPriceCents) }}</s>
|
||||
@endif
|
||||
<span class="sr-only">{{ $line->state === 'preis_geaendert' ? 'Neuer Preis: ' : 'Preis: ' }}</span>{{ \App\Domain\Commerce\Money::format($line->currentPriceCents) }}
|
||||
</p>
|
||||
@endif
|
||||
<div class="shop-actions">
|
||||
@if (in_array($line->state, ['preis_geaendert', 'bedingungen_geaendert'], true))
|
||||
<form method="post" action="{{ route('cart.accept', $line->offer) }}">
|
||||
@csrf
|
||||
<button class="button button-secondary" type="submit">{{ $line->state === 'preis_geaendert' ? 'Neuen Preis übernehmen' : 'Neue Bedingungen übernehmen' }}<span class="sr-only">: {{ $line->offer->optionName() }}</span></button>
|
||||
</form>
|
||||
@endif
|
||||
@if ($line->state === 'bereits_erworben' && $review->holder?->type->value !== 'organisation')
|
||||
<a class="button button-secondary" href="{{ route('member.library') }}">Zur Bibliothek</a>
|
||||
@endif
|
||||
<form method="post" action="{{ route('cart.remove', $line->offer) }}">
|
||||
@csrf
|
||||
<button class="button button-quiet" type="submit">Entfernen<span class="sr-only">: {{ $line->offer->optionName() }}</span></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<div class="shop-total">
|
||||
<p><span>Summe</span> <strong>{{ \App\Domain\Commerce\Money::format($review->totalCents()) }}</strong></p>
|
||||
<p class="shop-note">Testzahlung. Es wird kein echtes Geld bewegt.</p>
|
||||
</div>
|
||||
|
||||
@if ($review->blocked())
|
||||
<p class="shop-note" role="status">Entferne die Positionen, die nicht bestellt werden können, oder wähle einen passenden Lizenzinhaber. Die übrigen Positionen bleiben bestellbar.</p>
|
||||
@elseif ($review->empty())
|
||||
<p class="shop-note" role="status">Es gibt nichts zu bestellen: Alle Positionen sind bereits erworben. Du kannst sie entfernen oder die Bibliothek öffnen.</p>
|
||||
@endif
|
||||
|
||||
@if (! $review->blocked() && ! $review->empty())
|
||||
@auth
|
||||
<a class="button" href="{{ route('checkout', array_filter(['bestellen_als' => $review->holder?->id])) }}">Zur Kasse</a>
|
||||
@else
|
||||
<p class="shop-note">Für die Bestellung brauchst du ein Konto. Dein Warenkorb bleibt dabei erhalten.</p>
|
||||
<p class="shop-actions">
|
||||
<a class="button" href="{{ route('checkout') }}">Anmelden und zur Kasse</a>
|
||||
<a class="button button-secondary" href="{{ route('register') }}">Registrieren</a>
|
||||
</p>
|
||||
@endauth
|
||||
@else
|
||||
<button class="button" type="button" disabled aria-disabled="true">Zur Kasse</button>
|
||||
@endif
|
||||
@endif
|
||||
@endsection
|
||||
@@ -0,0 +1,88 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', 'Bestellübersicht')
|
||||
|
||||
@section('content')
|
||||
<h1>Bestellübersicht</h1>
|
||||
<p class="lede">Prüfe deine Bestellung. Preis und Bedingungen gelten so, wie sie hier stehen. Bezahlt wird im nächsten Schritt mit der Testzahlung.</p>
|
||||
|
||||
@if ($errors->any())
|
||||
<p class="errors" role="alert">{{ $errors->first() }}</p>
|
||||
@endif
|
||||
|
||||
@if ($holders->count() > 1)
|
||||
<form class="shop-holder" method="get" action="{{ route('checkout') }}">
|
||||
<label for="bestellen_als">Bestellen als</label>
|
||||
<select id="bestellen_als" name="bestellen_als">
|
||||
@foreach ($holders as $holder)
|
||||
<option value="{{ $holder->id }}" @selected($review->holder?->id === $holder->id)>{{ $holder->display_name }} ({{ $holder->type->value === 'person' ? 'Privatperson' : 'Verein oder Organisation' }})</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<button class="button button-secondary" type="submit">Übernehmen</button>
|
||||
</form>
|
||||
@elseif ($review->holder)
|
||||
<p>Lizenzinhaber: <strong>{{ $review->holder->display_name }}</strong></p>
|
||||
@endif
|
||||
|
||||
@if ($review->holder?->type->value === 'organisation')
|
||||
<p class="shop-note">Der Verein ist Lizenzinhaber. Herunterladen kann nur dieses Konto, das die Bestellung auslöst.</p>
|
||||
@endif
|
||||
|
||||
<ul class="shop-lines shop-order-summary">
|
||||
@foreach ($review->lines as $line)
|
||||
<li @class(['shop-line', 'is-owned' => $line->state === 'bereits_erworben', 'is-blocked' => $line->blocks()])>
|
||||
<div class="shop-line-main">
|
||||
<h2>{{ $line->title() }}</h2>
|
||||
<p class="shop-line-option">{{ $line->offer->optionName() }}</p>
|
||||
@if ($line->state === 'bereits_erworben')
|
||||
<p class="shop-badge shop-badge-owned">Bereits erworben · Wird nicht mitbestellt</p>
|
||||
@elseif ($line->blocks())
|
||||
<p class="shop-badge shop-badge-blocked">{{ $line->state === 'zurueckgezogen' ? 'Nicht mehr erhältlich' : 'Passt nicht zum Lizenzinhaber' }}</p>
|
||||
<p class="shop-note">{{ $line->note }}</p>
|
||||
@elseif ($line->state === 'preis_geaendert')
|
||||
<p class="shop-badge shop-badge-changed">Preis geändert</p>
|
||||
<p class="shop-note">Bisher {{ \App\Domain\Commerce\Money::format($line->seenPriceCents) }}, jetzt {{ \App\Domain\Commerce\Money::format($line->currentPriceCents) }}.</p>
|
||||
@elseif ($line->state === 'bedingungen_geaendert')
|
||||
<p class="shop-badge shop-badge-changed">Bedingungen aktualisiert</p>
|
||||
<p class="shop-note">{{ $line->note }}</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="shop-line-side">
|
||||
@if ($line->currentPriceCents !== null)
|
||||
<p @class(['shop-price', 'is-struck' => $line->state === 'bereits_erworben'])><span class="sr-only">Preis: </span>{{ \App\Domain\Commerce\Money::format($line->currentPriceCents) }}</p>
|
||||
@endif
|
||||
</div>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<div class="shop-total">
|
||||
<p><span>Summe</span> <strong>{{ \App\Domain\Commerce\Money::format($review->totalCents()) }}</strong></p>
|
||||
<p class="shop-note">Testzahlung. Es wird kein echtes Geld bewegt.</p>
|
||||
</div>
|
||||
|
||||
<div class="shop-actions">
|
||||
@if ($review->canOrder())
|
||||
<form method="post" action="{{ route('checkout.place') }}">
|
||||
@csrf
|
||||
<input type="hidden" name="digest" value="{{ $review->digest() }}">
|
||||
@if ($review->holder)<input type="hidden" name="bestellen_als" value="{{ $review->holder->id }}">@endif
|
||||
<button class="button" type="submit">Bestellung anlegen</button>
|
||||
</form>
|
||||
@else
|
||||
<button class="button" type="button" disabled aria-disabled="true">Bestellung anlegen</button>
|
||||
@endif
|
||||
<a class="button button-secondary" href="{{ route('cart') }}">Zurück zum Warenkorb</a>
|
||||
</div>
|
||||
@if (! $review->canOrder())
|
||||
<p class="shop-note" role="status">
|
||||
@if ($review->holder === null)
|
||||
Für diesen Lizenzinhaber kannst du nicht bestellen. Wähle oben einen anderen Lizenzinhaber oder bestelle als Privatperson.
|
||||
@elseif ($review->blocked())
|
||||
Entferne zuerst die Positionen, die nicht bestellt werden können, oder wähle einen passenden Lizenzinhaber.
|
||||
@else
|
||||
Es gibt nichts zu bestellen. Alle Positionen sind bereits erworben.
|
||||
@endif
|
||||
</p>
|
||||
@endif
|
||||
@endsection
|
||||
@@ -0,0 +1,35 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', 'Shop')
|
||||
|
||||
@section('content')
|
||||
<h1>Shop</h1>
|
||||
<p class="lede">Hier findest du kaufbare Programme. Jede Kachel öffnet die Produktseite mit Inhalt und den verfügbaren Lizenzoptionen.</p>
|
||||
|
||||
<form class="shop-search" method="get" action="{{ route('shop') }}" role="search">
|
||||
<label for="shop-suche">Shop durchsuchen</label>
|
||||
<input id="shop-suche" type="search" name="suche" value="{{ $term }}" autocomplete="off">
|
||||
<button class="button" type="submit">Suchen</button>
|
||||
@if ($term !== '')
|
||||
<a class="button button-quiet" href="{{ route('shop') }}">Suche zurücksetzen</a>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
@if ($cards === [])
|
||||
<div class="empty">
|
||||
<h2>{{ $term !== '' ? 'Keine Treffer' : 'Noch keine kaufbaren Produkte' }}</h2>
|
||||
<p>{{ $term !== '' ? 'Zu „'.$term.'“ gibt es keine kaufbaren Produkte. Prüfe die Schreibweise oder setze die Suche zurück.' : 'Sobald ein Angebot aktiv ist, erscheint es hier.' }}</p>
|
||||
</div>
|
||||
@else
|
||||
<p class="shop-count" role="status">{{ count($cards) }} {{ count($cards) === 1 ? 'Produkt' : 'Produkte' }}</p>
|
||||
<ul class="shop-tiles">
|
||||
@foreach ($cards as $card)
|
||||
<li class="shop-tile">
|
||||
<h2><a href="{{ route('public.program', $card['composition']) }}">{{ $card['title'] }}</a></h2>
|
||||
@if ($card['teaser'] !== '')<p>{{ $card['teaser'] }}</p>@endif
|
||||
<p class="shop-tile-price">ab {{ $card['from'] }} · {{ $card['count'] }} {{ $card['count'] === 1 ? 'Lizenzoption' : 'Lizenzoptionen' }}</p>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@endsection
|
||||
@@ -0,0 +1,64 @@
|
||||
{{--
|
||||
Kaufbare Lizenzoptionen unter dem fachlichen Inhalt einer Produktseite.
|
||||
Parameter: $options (ProductOptions), $cart (Cart), $switchTo (Angebotskennung eines ausstehenden Wechsels)
|
||||
--}}
|
||||
@if ($options !== [])
|
||||
<section class="shop-options" aria-labelledby="shop-options-title">
|
||||
<h2 id="shop-options-title">Lizenzoptionen</h2>
|
||||
<p class="shop-options-lede">Wähle die Lizenz, die zu deiner Nutzung passt. Jede Option ist einzeln kaufbar. Preis und Bedingungen gelten ab dem Bestellabschluss; es wird nichts reserviert.</p>
|
||||
|
||||
@if ($errors->has('shop'))
|
||||
<p class="errors" role="alert">{{ $errors->first('shop') }}</p>
|
||||
@endif
|
||||
|
||||
@if ($switchTo)
|
||||
@php
|
||||
$wanted = collect($options)->first(fn ($option) => $option['offer']->id === (int) $switchTo);
|
||||
$current = $wanted ? $cart->alternativeTo($wanted['offer']) : null;
|
||||
@endphp
|
||||
@if ($wanted && $current)
|
||||
<div class="shop-switch ui-notice ui-notice-warning" role="region" aria-labelledby="shop-switch-title">
|
||||
<p id="shop-switch-title" class="ui-notice-title">Optionen wechseln?</p>
|
||||
<p>In deinem Warenkorb liegt bereits „{{ $current->optionName() }}“. Diese Produktseite wird nur mit einer Option bestellt. Möchtest du zu „{{ $wanted['name'] }}“ wechseln?</p>
|
||||
<div class="shop-actions">
|
||||
<form method="post" action="{{ route('cart.switch', $wanted['offer']) }}">
|
||||
@csrf
|
||||
<button class="button" type="submit">Zu „{{ $wanted['name'] }}“ wechseln</button>
|
||||
</form>
|
||||
<a class="button button-secondary" href="{{ route('public.program', $wanted['offer']->composition_id) }}">Bei „{{ $current->optionName() }}“ bleiben</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
<ul class="shop-option-list">
|
||||
@foreach ($options as $option)
|
||||
<li class="shop-option">
|
||||
<h3>{{ $option['name'] }}</h3>
|
||||
<p class="shop-price"><span class="sr-only">Preis: </span>{{ $option['price'] }}</p>
|
||||
<dl class="shop-facts">
|
||||
<div><dt>Geeignet für</dt><dd>{{ $option['for'] }}</dd></div>
|
||||
<div><dt>Laufzeit</dt><dd>{{ $option['term'] }}</dd></div>
|
||||
</dl>
|
||||
<h4>Umfang und Nutzungsrechte</h4>
|
||||
<ul class="shop-scope">
|
||||
@foreach ($option['scope'] as $item)
|
||||
<li>
|
||||
<strong>{{ $item['article'] }}</strong>
|
||||
<span>{{ $item['purpose'] }}@if ($item['rights'] !== []): {{ implode(', ', $item['rights']) }}@endif</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@if ($cart->has($option['offer']))
|
||||
<p class="shop-in-cart">Im Warenkorb. <a href="{{ route('cart') }}">Zum Warenkorb</a></p>
|
||||
@else
|
||||
<form method="post" action="{{ route('cart.add', $option['offer']) }}">
|
||||
@csrf
|
||||
<button class="button" type="submit">In den Warenkorb<span class="sr-only">: {{ $option['name'] }}</span></button>
|
||||
</form>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</section>
|
||||
@endif
|
||||
Reference in new issue
Block a user