diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index f10a1faa..d31b5d4f 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -36,15 +36,7 @@ class MemberController extends Controller session()->put('title', 'Mitglied erstellen'); return \Inertia::render('member/VForm', [ - 'data' => [ - 'country_id' => Country::default(), - 'efz' => null, - 'ps_at' => null, - 'without_education_at' => null, - 'without_efz_at' => null, - 'more_ps_at' => null, - 'joined_at' => now()->format('Y-m-d'), - ], + 'data' => MemberResource::defaultModel(), 'mode' => 'create', 'meta' => MemberResource::meta(), ]); diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 6ad2fd34..99e46acd 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -149,4 +149,51 @@ class MemberResource extends JsonResource ], ]; } + + /** + * @return array + */ + public static function defaultModel(): array + { + return [ + 'gender_id' => null, + 'salutation' => '', + 'nationality_id' => null, + 'firstname' => '', + 'lastname' => '', + 'address' => '', + 'further_address' => '', + 'zip' => '', + 'location' => '', + 'birthday' => '', + 'region_id' => null, + 'country_id' => Country::default(), + 'other_country' => '', + 'main_phone' => '', + 'mobile_phone' => '', + 'work_phone' => '', + 'children_phone' => '', + 'email' => '', + 'email_parents' => '', + 'fax' => '', + 'letter_address' => '', + 'bill_kind' => null, + 'subscription_id' => null, + 'has_nami' => false, + 'send_newspaper' => false, + 'joined_at' => now()->format('Y-m-d'), + 'comment' => '', + 'first_activity_id' => null, + 'first_subactivity_id' => null, + 'efz' => null, + 'ps_at' => null, + 'more_ps_at' => null, + 'without_education_at' => null, + 'without_efz_at' => null, + 'has_vk' => false, + 'has_svk' => false, + 'multiply_pv' => false, + 'multiply_more_pv' => false, + ]; + } } diff --git a/tests/Feature/Member/CreateTest.php b/tests/Feature/Member/CreateTest.php index b935b625..5efbccfc 100644 --- a/tests/Feature/Member/CreateTest.php +++ b/tests/Feature/Member/CreateTest.php @@ -32,7 +32,14 @@ class CreateTest extends TestCase $this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}"); $this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0'); - $this->assertInertiaHas(['efz' => null, 'ps_at' => null, 'more_ps_at' => null, 'without_education_at' => null, 'without_efz_at' => null], $response, 'data'); + $this->assertInertiaHas([ + 'efz' => null, + 'ps_at' => null, + 'more_ps_at' => null, + 'without_education_at' => null, + 'without_efz_at' => null, + 'address' => '', + ], $response, 'data'); } public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void diff --git a/tests/Feature/Member/StoreTest.php b/tests/Feature/Member/StoreTest.php index 268cfd8f..69ca4132 100644 --- a/tests/Feature/Member/StoreTest.php +++ b/tests/Feature/Member/StoreTest.php @@ -75,9 +75,10 @@ class StoreTest extends TestCase 'salutation' => 'Doktor', 'comment' => 'Lorem bla', ]); - NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member) - && $activityParam->is($activity) - && $subactivityParam->is($subactivity) + NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs( + fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member) + && $activityParam->is($activity) + && $subactivityParam->is($subactivity) )->once(); }