Skip to content
Permalink
Browse files

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.
  • Loading branch information...
damyon committed May 9, 2013
1 parent 8cfc9d7 commit e9df9e8f7abbb70cb41b813557f80ec824dd5993
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/conditionlib.php
  2. +9 −0 lib/tests/conditionlib_test.php
@@ -1325,7 +1325,7 @@ protected function get_cached_user_profile_field($userid, $fieldid) {
$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 @@ public function test_condition_user_fields() {
// 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));
}
}
}

0 comments on commit e9df9e8

Please sign in to comment.
You can’t perform that action at this time.