diff --git a/src/Casters/GenderCast.php b/src/Casters/GenderCast.php new file mode 100644 index 0000000..5ffeb38 --- /dev/null +++ b/src/Casters/GenderCast.php @@ -0,0 +1,20 @@ + $this->nickname ?: '', 'vorname' => $this->firstname ?: '', 'nachname' => $this->lastname ?: '', - 'geschlechtId' => $this->genderId, + 'geschlechtId' => $this->genderId ?: 23, 'email' => $this->email, 'beitragsartId' => $this->feeId, 'geburtsDatum' => $this->birthday->format('Y-m-d 00:00:00'), diff --git a/tests/Unit/Api/FetchMemberTest.php b/tests/Unit/Api/FetchMemberTest.php index dbdcf44..f8eaeb6 100644 --- a/tests/Unit/Api/FetchMemberTest.php +++ b/tests/Unit/Api/FetchMemberTest.php @@ -91,6 +91,7 @@ class FetchMemberTest extends TestCase 'mitgliedsNummer' => null, 'beitragsartId' => null, 'konfessionId' => null, + 'geschlechtId' => 23, ]); $member = $this->login()->member(1000, 1001); @@ -108,6 +109,7 @@ class FetchMemberTest extends TestCase $this->assertNull($member->memberId); $this->assertNull($member->feeId); $this->assertNull($member->confessionId); + $this->assertNull($member->genderId); } public function testMemberFetchCanFail(): void diff --git a/tests/Unit/Api/PutMemberTest.php b/tests/Unit/Api/PutMemberTest.php index 58802fa..8ca1e25 100644 --- a/tests/Unit/Api/PutMemberTest.php +++ b/tests/Unit/Api/PutMemberTest.php @@ -138,4 +138,21 @@ class PutMemberTest extends TestCase 'foreign' => 'fff', ]); } + + public function testGenderCanBeNull(): void + { + app(MemberFake::class) + ->updatesSuccessfully(103, 16) + ->shows(103, 16, [ + 'foreign' => 'fff', + 'kontoverbindung' => ['a' => 'b'], + ]); + $response = $this->login()->putMember(Member::factory()->inNami(103, 16)->toMember(['genderId' => null])); + + $this->assertEquals(16, $response); + + app(MemberFake::class)->assertUpdated(103, 16, [ + 'geschlechtId' => 23, + ]); + } }