FIX: Correct return type for Member::currentUser()

This commit is contained in:
Loz Calver 2016-11-09 12:45:40 +00:00
parent 1ec56a1202
commit 6bf36fbd30
No known key found for this signature in database
GPG Key ID: F91FFC2D7E0CAEDB
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);
}
}
/**