From 39bf3fc7f84bfe666fcb917ac818ee2effd2c73a Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 4 Jul 2020 01:46:03 +0200 Subject: [PATCH] Fixed: Joined_at can be null --- src/Member.php | 10 ++++------ tests/Unit/PullMemberTest.php | 13 ++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Member.php b/src/Member.php index b0bd721..8ae4a3e 100644 --- a/src/Member.php +++ b/src/Member.php @@ -78,14 +78,12 @@ class Member extends Model { $this->attributes['gender_id'] = data_get($this->geschlechtMaps, $v, null); } - public function getAttributeValue($key) { - $original = parent::getAttributeValue($key); - - if (in_array($key, $this->nullable) && $original === '') { - return null; + public function setAttribute($key, $value) { + if (in_array($key, $this->nullable) && $value === '') { + return parent::setAttribute($key, null); } - return $original; + return parent::setAttribute($key, $value); } } diff --git a/tests/Unit/PullMemberTest.php b/tests/Unit/PullMemberTest.php index 3ed575c..25793ec 100644 --- a/tests/Unit/PullMemberTest.php +++ b/tests/Unit/PullMemberTest.php @@ -79,8 +79,8 @@ class PullMemberTest extends TestCase $group = Nami::group(103); - $this->assertSame($values[0], $group->member(16)->{$key}); - $this->assertSame($values[1], $group->member(17)->{$key}); + $this->assertSame($values[0], $group->member(16)->toArray()[$key]); + $this->assertSame($values[1], $group->member(17)->toArray()[$key]); Http::assertSentCount(5); } @@ -100,10 +100,9 @@ class PullMemberTest extends TestCase Nami::login(); - $this->assertSame([ - 16 => $values[0], - 17 => $values[1] - ], Nami::group(103)->members()->pluck($key, 'id')->toArray()); + $member = Nami::group(103)->members(); + $this->assertSame($values[0], $member->get(0)->toArray()[$key]); + $this->assertSame($values[1], $member->get(1)->toArray()[$key]); Http::assertSentCount(6); } @@ -147,7 +146,7 @@ class PullMemberTest extends TestCase $group = Nami::group(103); - $this->assertSame($values[0], $group->member(16)->{$key}); + $this->assertSame($values[0], $group->member(16)->toArray()[$key]); Http::assertSentCount(5); }