mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX: Correct return type for Member::currentUser()
This commit is contained in:
parent
1ec56a1202
commit
6bf36fbd30
@ -837,9 +837,8 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
$id = Member::currentUserID();
|
$id = Member::currentUserID();
|
||||||
|
|
||||||
if($id) {
|
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)');
|
$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…
x
Reference in New Issue
Block a user