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,82 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Etappe 1 (Testkauf): nur ergänzend, keine Daten werden gelöscht oder umbenannt.
|
||||
*
|
||||
* - Ein Angebot (Lizenzoption) kann auf die Komposition zeigen, deren öffentliche Seite die Produktseite ist
|
||||
* (`offers.composition_id`). Angebote derselben Komposition bilden die Angebotsgruppe (Alternativen).
|
||||
* - Mitgliedschaft eines Kontos in einer Organisation mit Bestellberechtigung (Domänenmodell 04, MEMBERSHIP).
|
||||
* - Der Erwerb hält das auslösende Konto, die Bestellung Gesamtsumme und Währung, die Position Inhaber, Währung,
|
||||
* Steuerklasse und Vergabeart als Kopie. `orders.party_id` ist der Lizenzinhaber, `orders.user_id` das handelnde Konto.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('offers', function (Blueprint $table) {
|
||||
$table->foreignId('composition_id')->nullable()->constrained('compositions')->nullOnDelete();
|
||||
$table->string('option_label')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('memberships', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('party_id')->constrained()->restrictOnDelete();
|
||||
$table->string('role')->default('mitglied');
|
||||
$table->boolean('may_order')->default(false);
|
||||
$table->date('valid_from')->nullable();
|
||||
$table->date('valid_until')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'party_id']);
|
||||
});
|
||||
|
||||
Schema::table('acquisitions', function (Blueprint $table) {
|
||||
$table->foreignId('acting_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->unsignedInteger('total_cents')->nullable();
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
});
|
||||
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
$table->string('tax_class')->nullable();
|
||||
$table->string('grant_kind')->nullable();
|
||||
$table->foreignId('holder_party_id')->nullable()->constrained('parties')->restrictOnDelete();
|
||||
});
|
||||
|
||||
// Bestehende Bestellungen: Summe und Inhaber der Position aus den vorhandenen Angaben.
|
||||
foreach (DB::table('orders')->get() as $order) {
|
||||
DB::table('orders')->where('id', $order->id)->update([
|
||||
'total_cents' => (int) DB::table('order_lines')->where('order_id', $order->id)->sum('price_cents'),
|
||||
]);
|
||||
DB::table('order_lines')->where('order_id', $order->id)->update(['holder_party_id' => $order->party_id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('holder_party_id');
|
||||
$table->dropColumn(['currency', 'tax_class', 'grant_kind']);
|
||||
});
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropColumn(['total_cents', 'currency']);
|
||||
});
|
||||
Schema::table('acquisitions', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('acting_user_id');
|
||||
});
|
||||
Schema::dropIfExists('memberships');
|
||||
Schema::table('offers', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('composition_id');
|
||||
$table->dropColumn('option_label');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user