From 04cfd95892f4a068e22aa957fc5b0cac6c9b9bc2 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 7 Feb 2023 22:48:33 +0100 Subject: [PATCH] Fixed: Joined at date can be null --- app/Actions/PullMemberAction.php | 4 ++-- packages/laravel-nami | 2 +- tests/Feature/Member/PullMemberActionTest.php | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Actions/PullMemberAction.php b/app/Actions/PullMemberAction.php index 26920695..d1029217 100644 --- a/app/Actions/PullMemberAction.php +++ b/app/Actions/PullMemberAction.php @@ -19,7 +19,7 @@ class PullMemberAction { use AsAction; - public function handle(int $groupId, int $memberId): Member + public function handle(int $groupId, int $memberId): ?Member { $member = $this->api()->member($groupId, $memberId); @@ -28,7 +28,7 @@ class PullMemberAction return Member::updateOrCreate(['nami_id' => $member->id], [ 'firstname' => $member->firstname, 'lastname' => $member->lastname, - 'joined_at' => $member->joinedAt, + 'joined_at' => $member->joinedAt ?: now(), 'birthday' => $member->birthday, 'send_newspaper' => $member->sendNewspaper, 'address' => $member->address, diff --git a/packages/laravel-nami b/packages/laravel-nami index fca340c5..e96d3dfe 160000 --- a/packages/laravel-nami +++ b/packages/laravel-nami @@ -1 +1 @@ -Subproject commit fca340c520916db554b6bfa4562dd14ef97d1b35 +Subproject commit e96d3dfe8eba1cbcb0eedc67ade07337170a7507 diff --git a/tests/Feature/Member/PullMemberActionTest.php b/tests/Feature/Member/PullMemberActionTest.php index 11d9ed4e..a4871703 100644 --- a/tests/Feature/Member/PullMemberActionTest.php +++ b/tests/Feature/Member/PullMemberActionTest.php @@ -91,4 +91,15 @@ class PullMemberActionTest extends TestCase 'region_id' => null, ]); } + + public function testFetchesMembersWhenJoinedAtDateIsNull(): void + { + app(MemberFake::class)->shows(1000, 1001, [ + 'eintrittsdatum' => null, + ]); + + app(PullMemberAction::class)->handle(1000, 1001); + + $this->assertDatabaseCount('members', 1); + } }