mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 21:45:37 +02:00
MDL-38289: Custom profile fields - added unit test
Added a unit test to cover the case when you are fetching a custom profile field but you are not logged in.
This commit is contained in:
parent
8cfc9d75ed
commit
e9df9e8f7a
@ -1325,7 +1325,7 @@ abstract class condition_info_base {
|
||||
$iscurrentuser = $USER->id == $userid;
|
||||
|
||||
if (isguestuser($userid) || ($iscurrentuser && !isloggedin())) {
|
||||
// Must be logged in and can't be the guest. (this should never happen anyway)
|
||||
// Must be logged in and can't be the guest. (e.g. front page)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -776,6 +776,15 @@ class conditionlib_testcase extends advanced_testcase {
|
||||
// without error.
|
||||
$ci->get_cached_user_profile_field($USER->id, $fieldid);
|
||||
}
|
||||
|
||||
// Change to not logged in user.
|
||||
$this->setUser(null);
|
||||
|
||||
foreach ($fields as $fieldid => $name) {
|
||||
// Should get false always when not logged in.
|
||||
$this->assertEquals(false, $ci->get_cached_user_profile_field($USER->id, $fieldid));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user