Support oft parent groups

This commit is contained in:
2026-09-29 14:35:33 +02:00
parent c4ca101594
commit a5e4e55df5
86 changed files with 1936 additions and 80 deletions
+65 -2
View File
@@ -7,10 +7,12 @@ use App\Domains\Event\Actions\ShortSignUp\ShortSignUpRequest;
use App\Enumerations\EatingHabit;
use App\Enumerations\EfzStatus;
use App\Enumerations\FirstAidPermission;
use App\Enumerations\ParticipantGroupType;
use App\Enumerations\ParticipationType;
use App\Enumerations\SwimmingPermission;
use App\Models\Event;
use App\Models\EventParticipant;
use App\Models\ParentGroup;
use App\Models\PaymentMethod;
use App\Models\Tenant;
use App\RelationModels\EventParticipationFee;
@@ -294,7 +296,7 @@ class ShortSignUpTest extends TestCase
$this->assertSame(0, EventParticipant::count());
}
private function createLocalGroup(string $slug, string $name): Tenant
private function createLocalGroup(string $slug, string $name, ?ParentGroup $parentGroup = null): Tenant
{
return Tenant::create([
'slug' => $slug, 'name' => $name, 'email' => $slug . '@example.com',
@@ -302,9 +304,70 @@ class ShortSignUpTest extends TestCase
'account_name' => $name, 'account_iban' => 'DE00', 'account_bic' => 'XY',
'city' => 'Stadt', 'postcode' => '00000', 'is_active_local_group' => true,
'has_active_instance' => false,
'parent_group_id' => $parentGroup?->id,
]);
}
public function test_bund_abfrage_ordnet_einzigen_bund_ohne_auswahl_zu(): void
{
$event = $this->createEvent();
$event->update(['participant_group_type' => ParticipantGroupType::ParentGroup->value]);
$bdp = ParentGroup::where('name', 'BdP')->firstOrFail();
// Zwei Stämme desselben Bundes ergeben genau eine Option.
$event->localGroups()->attach([
$this->createLocalGroup('stamm-a', 'Stamm A', $bdp)->id,
$this->createLocalGroup('stamm-b', 'Stamm B', $bdp)->id,
]);
$event->refresh();
$response = new ShortSignUpCommand($this->shortRequest($event))->execute();
$this->assertTrue($response->success, $response->message ?? '');
$this->assertSame($bdp->id, $response->participant->parent_group_id);
$this->assertNull($response->participant->local_group);
$this->assertSame('BdP', $response->participant->toResource()->toArray(request())['participantGroup']);
}
public function test_bund_abfrage_uebernimmt_gewaehlten_bund(): void
{
$event = $this->createEvent();
$event->update(['participant_group_type' => ParticipantGroupType::ParentGroup->value]);
$bdp = ParentGroup::where('name', 'BdP')->firstOrFail();
$vcp = ParentGroup::where('name', 'VCP')->firstOrFail();
$event->localGroups()->attach([
$this->createLocalGroup('stamm-a', 'Stamm A', $bdp)->id,
$this->createLocalGroup('stamm-b', 'Stamm B', $vcp)->id,
]);
$event->refresh();
$response = new ShortSignUpCommand($this->shortRequest($event, [
'localGroupId' => $vcp->id,
]))->execute();
$this->assertTrue($response->success, $response->message ?? '');
$this->assertSame($vcp->id, $response->participant->parent_group_id);
}
public function test_bund_abfrage_lehnt_nicht_beteiligten_bund_ab(): void
{
$event = $this->createEvent();
$event->update(['participant_group_type' => ParticipantGroupType::ParentGroup->value]);
$event->localGroups()->attach([
$this->createLocalGroup('stamm-a', 'Stamm A', ParentGroup::where('name', 'BdP')->firstOrFail())->id,
$this->createLocalGroup('stamm-b', 'Stamm B', ParentGroup::where('name', 'VCP')->firstOrFail())->id,
]);
$event->refresh();
// Der Bund existiert, aber kein teilnehmender Stamm gehört zu ihm.
$response = new ShortSignUpCommand($this->shortRequest($event, [
'localGroupId' => ParentGroup::where('name', 'DPSG')->firstOrFail()->id,
]))->execute();
$this->assertFalse($response->success);
$this->assertSame('Bitte bei „Bund" eine Auswahl treffen.', $response->message);
$this->assertSame(0, EventParticipant::count());
}
public function test_einziger_stamm_wird_ohne_auswahl_zugeordnet(): void
{
$event = $this->createEvent();
@@ -377,7 +440,7 @@ class ShortSignUpTest extends TestCase
// Regressionswächter für Teilnehmerliste, Detailansicht und CSV-Export.
$array = $response->participant->toResource()->toArray(request());
$this->assertSame('Nicht im LV', $array['localgroup']);
$this->assertSame('Nicht im LV', $array['participantGroup']);
$this->assertSame('Erteilt', $array['swimmingPermission']);
$this->assertSame('Zugestimmt', $array['extendedFirstAid']);
$this->assertSame('Omnivor', $array['eatingHabit']);