Skip to content
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...
1 parent 3f999f8 commit 93c5c3b02c9bf85f6a41a1c3929d950490e7dd3c @damyon damyon committed May 9, 2013
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/conditionlib.php
  2. +9 −0 lib/tests/conditionlib_test.php
View
2 lib/conditionlib.php
@@ -1280,7 +1280,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;
}
View
9 lib/tests/conditionlib_test.php
@@ -775,6 +775,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 93c5c3b

Please sign in to comment.
Something went wrong with that request. Please try again.