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
@@ -5,8 +5,11 @@
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use App\Domain\Commerce\StaleOverview;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -48,10 +51,50 @@ public function place(Request $request, Offer $offer, Checkout $checkout): Redir
|
||||
return redirect()->route('member.order', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
|
||||
*/
|
||||
public function checkout(Request $request, Cart $cart, OrderHolders $holders): View|RedirectResponse
|
||||
{
|
||||
if ($cart->count() === 0) {
|
||||
return redirect()->route('cart');
|
||||
}
|
||||
|
||||
$review = $cart->review($request->user(), $request->integer('bestellen_als') ?: null);
|
||||
|
||||
return view('shop.checkout', [
|
||||
'review' => $review,
|
||||
'holders' => $holders->for($request->user()),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt die Bestellung an, aber nur, wenn die serverseitige Prüfung zur gezeigten Übersicht passt.
|
||||
*/
|
||||
public function placeOrder(Request $request, Cart $cart, Checkout $checkout): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'digest' => ['required', 'string'],
|
||||
'bestellen_als' => ['nullable', 'integer'],
|
||||
]);
|
||||
$holderId = isset($data['bestellen_als']) ? (int) $data['bestellen_als'] : null;
|
||||
$back = redirect()->route('checkout', array_filter(['bestellen_als' => $holderId]));
|
||||
|
||||
try {
|
||||
$order = $checkout->placeFromCart($request->user(), $cart, $holderId, $data['digest']);
|
||||
} catch (StaleOverview $exception) {
|
||||
return $back->withErrors(['checkout' => $exception->getMessage()]);
|
||||
} catch (DomainRuleException $exception) {
|
||||
return $back->withErrors(['checkout' => $exception->getMessage()]);
|
||||
}
|
||||
|
||||
return redirect()->route('member.order', $order)->with('status', 'Die Bestellung ist angelegt. Bestätige jetzt die Testzahlung.');
|
||||
}
|
||||
|
||||
public function show(Request $request, Order $order): View
|
||||
{
|
||||
abort_unless($order->user_id === $request->user()->id, 403);
|
||||
$order->load('lines.offerVersion.offer', 'payments');
|
||||
$order->load('lines.offerVersion.offer', 'lines.holder', 'payments', 'party', 'user');
|
||||
|
||||
return view('member.order', [
|
||||
'order' => $order,
|
||||
|
||||
@@ -466,7 +466,7 @@ private function grantQuery(Request $request)
|
||||
{
|
||||
return Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $request->user()->party_id))
|
||||
->usableBy($request->user())
|
||||
->with('article.currentRelease')
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user