Merge pull request #6304 from kinglozzer/member-currentuser

FIX: Correct return type for Member::currentUser()
This commit is contained in:
Daniel Hensby 2016-11-09 15:59:44 +00:00 committed by GitHub
commit d2f6ff4873
2 changed files with 11 additions and 2 deletions

View File

@ -837,9 +837,8 @@ class Member extends DataObject implements TemplateGlobalProvider {
$id = Member::currentUserID();
if($id) {
return DataObject::get_by_id('Member', $id);
return DataObject::get_by_id('Member', $id) ?: null;
}
return null;
}
/**

View File

@ -1041,6 +1041,16 @@ class MemberTest extends FunctionalTest {
$this->assertTrue($fail, 'Passes with email and surname now (no firstname)');
}
public function testCurrentUser() {
$this->assertNull(Member::currentUser());
$adminMember = $this->objFromFixture('Member', 'admin');
$this->logInAs($adminMember);
$userFromSession = Member::currentUser();
$this->assertEquals($adminMember->ID, $userFromSession->ID);
}
}
/**