mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #6304 from kinglozzer/member-currentuser
FIX: Correct return type for Member::currentUser()
This commit is contained in:
commit
d2f6ff4873
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user