Fix für Short-Signups

This commit is contained in:
2026-09-10 22:27:57 +02:00
parent 4e981c140b
commit 328825293a
13 changed files with 242 additions and 57 deletions
+58 -3
View File
@@ -50,7 +50,12 @@ class ShortSignUpTest extends TestCase
EatingHabit::create(['slug' => EatingHabit::EATING_HABIT_OMNIVOR, 'name' => 'Omnivor']);
}
private function createEvent(bool $withFee = true, bool $swimmingPermissionRequired = true): Event
private function createEvent(
bool $withFee = true,
bool $swimmingPermissionRequired = true,
?float $amountReduced = 30.0,
?float $amountSolidarity = 70.0,
): Event
{
$event = Event::create([
'tenant' => $this->tenant->slug, 'name' => 'Event', 'identifier' => 'evt-1', 'location' => 'Ort',
@@ -65,7 +70,7 @@ class ShortSignUpTest extends TestCase
$fee = EventParticipationFee::create([
'tenant' => $this->tenant->slug, 'type' => ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
'name' => 'Teilnahme', 'description' => '', 'amount_standard' => 50.0,
'amount_reduced' => 30.0, 'amount_solidarity' => 70.0,
'amount_reduced' => $amountReduced, 'amount_solidarity' => $amountSolidarity,
]);
$event->participation_fee_1 = $fee->id;
$event->save();
@@ -102,6 +107,7 @@ class ShortSignUpTest extends TestCase
paymentMethod: $overrides['paymentMethod'] ?? PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION,
paymentOptions: [],
participationOptions: $overrides['participationOptions'] ?? [],
feeType: $overrides['feeType'] ?? 'standard',
);
}
@@ -127,7 +133,7 @@ class ShortSignUpTest extends TestCase
$this->assertSame(1, $participant->arrival_eating);
$this->assertSame(2, $participant->departure_eating);
// Gruppe und Beitragsstufe stehen fest.
// Die Gruppe steht fest, ohne Wahl gilt der Standardbeitrag.
$this->assertSame(ParticipationType::PARTICIPATION_TYPE_PARTICIPANT, $participant->participation_type);
$this->assertSame('standard', $participant->fee_type);
$this->assertSame(50.0, $participant->amount->getAmount());
@@ -142,6 +148,55 @@ class ShortSignUpTest extends TestCase
$this->assertFalse($participant->foto_print);
}
public function test_gewaehlter_reduzierter_beitrag_wird_berechnet(): void
{
$event = $this->createEvent();
$response = new ShortSignUpCommand($this->shortRequest($event, ['feeType' => 'reduced']))->execute();
$this->assertTrue($response->success, $response->message ?? '');
$this->assertSame('reduced', $response->participant->fee_type);
$this->assertSame(30.0, $response->participant->amount->getAmount());
}
public function test_gewaehlter_solidaritaetsbeitrag_wird_berechnet(): void
{
$event = $this->createEvent();
$response = new ShortSignUpCommand($this->shortRequest($event, ['feeType' => 'solidarity']))->execute();
$this->assertTrue($response->success, $response->message ?? '');
$this->assertSame('solidarity', $response->participant->fee_type);
$this->assertSame(70.0, $response->participant->amount->getAmount());
}
public function test_nicht_hinterlegte_beitragsstufe_wird_abgelehnt(): void
{
$event = $this->createEvent(amountReduced: null);
$response = new ShortSignUpCommand($this->shortRequest($event, ['feeType' => 'reduced']))->execute();
$this->assertFalse($response->success);
$this->assertNotNull($response->message);
$this->assertSame(0, EventParticipant::count());
}
public function test_waehlbar_sind_nur_hinterlegte_beitragsstufen(): void
{
$this->assertSame(
['standard', 'reduced', 'solidarity'],
$this->createEvent()->firstParticipationFee()->availableFeeTypes()
);
$withoutReduced = EventParticipationFee::create([
'tenant' => $this->tenant->slug, 'type' => ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
'name' => 'Teilnahme', 'description' => '', 'amount_standard' => 50.0,
'amount_reduced' => null, 'amount_solidarity' => 70.0,
]);
$this->assertSame(['standard', 'solidarity'], $withoutReduced->availableFeeTypes());
}
public function test_u18_ohne_abgefragte_badeerlaubnis_bekommt_keine(): void
{
$event = $this->createEvent(swimmingPermissionRequired: false);