Merge branch 'MDL-58453-master' of git://github.com/jleyva/moodle
[moodle.git] / mod / feedback / tests / external_test.php
index 3763d59..0d91edb 100644 (file)
@@ -674,10 +674,25 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase {
         mod_feedback_external::get_non_respondents($this->feedback->id);
     }
 
+    /**
+     * Test get_non_respondents from an anonymous feedback.
+     */
+    public function test_get_non_respondents_from_anonymous_feedback() {
+        $this->setUser($this->student);
+        $this->expectException('moodle_exception');
+        $this->expectExceptionMessage(get_string('anonymous', 'feedback'));
+        mod_feedback_external::get_non_respondents($this->feedback->id);
+    }
+
     /**
      * Test get_non_respondents.
      */
     public function test_get_non_respondents() {
+        global $DB;
+
+        // Force non anonymous.
+        $DB->set_field('feedback', 'anonymous', FEEDBACK_ANONYMOUS_NO, array('id' => $this->feedback->id));
+
         // Create another student.
         $anotherstudent = self::getDataGenerator()->create_user();
         $this->getDataGenerator()->enrol_user($anotherstudent->id, $this->course->id, $this->studentrole->id, 'manual');