Add feature tests for shop functionality and organization purchases
Deploy Test / test (push) Successful in 1m38s
Deploy Test / deploy (push) Successful in 31s

- 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:
Lars committed 2026-11-21 12:06:24 +01:00
1 parent 6c8bbee363
commit 4e0760db1e
106 files changed
+4068 -76

No files matched your search

+51
View File
@@ -22,6 +22,23 @@ public function currentActiveVersion(Offer $offer): OfferVersion
return $version;
}
/**
* Die aktive, als Kauf angebotene Fassung mit Preis; sonst null (nicht kaufbar, zurückgezogen oder kostenlos).
*/
public function purchasableVersion(Offer $offer): ?OfferVersion
{
$version = $offer->versions()
->where('status', OfferStatus::Aktiv)
->orderByDesc('number')
->first();
if ($version === null || $version->grant_kind !== 'kauf' || $version->price_cents === null) {
return null;
}
return $version;
}
/**
* @param array<string, mixed> $capabilities
* @param array<string, mixed> $options
@@ -138,6 +155,40 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
});
}
/**
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
* zurückgezogen und blockieren den Abschluss, bis der Käufer sie entfernt.
*/
public function end(Offer $offer): OfferVersion
{
return DB::transaction(function () use ($offer): OfferVersion {
$offer = Offer::query()->lockForUpdate()->findOrFail($offer->id);
$version = $this->currentActiveVersion($offer);
$version->status = OfferStatus::Beendet;
$version->save();
return $version;
});
}
/**
* Produktzuordnung der Option: Die Komposition bestimmt die öffentliche Produktseite und die Alternativgruppe,
* die Bezeichnung benennt die Option auf dieser Seite. Beides sind keine bindenden Konditionen.
*/
public function assignProduct(Offer $offer, ?int $compositionId, ?string $optionLabel): Offer
{
if ($compositionId !== null) {
Composition::query()->findOrFail($compositionId);
}
$offer->composition_id = $compositionId;
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
$offer->save();
return $offer;
}
/**
* @return list<int>
*/