MDL-62755 mod_assign: Update to unit tests.
authorAdrian Greeve <adrian@moodle.com>
Wed, 20 Jun 2018 05:42:15 +0000 (13:42 +0800)
committerAdrian Greeve <adrian@moodle.com>
Mon, 25 Jun 2018 01:49:13 +0000 (09:49 +0800)
Overrides are now checked to be exported properly.

mod/assign/tests/privacy_test.php

index ac2ee02..bcae99d 100644 (file)
@@ -152,6 +152,7 @@ class mod_assign_privacy_testcase extends provider_testcase {
      * Test that a student with multiple submissions and grades is returned with the correct data.
      */
     public function test_export_user_data_student() {
+        global $DB;
         $this->resetAfterTest();
         $course = $this->getDataGenerator()->create_course();
         $coursecontext = \context_course::instance($course->id);
@@ -176,6 +177,14 @@ class mod_assign_privacy_testcase extends provider_testcase {
 
         $this->setUser($teacher);
 
+        $overridedata = new \stdClass();
+        $overridedata->assignid = $assign->get_instance()->id;
+        $overridedata->userid = $user->id;
+        $overridedata->duedate = time();
+        $overridedata->allowsubmissionsfromdate = time();
+        $overridedata->cutoffdate = time();
+        $DB->insert_record('assign_overrides', $overridedata);
+
         $grade1 = '67.00';
         $teachercommenttext = 'Please try again.';
         $data = new \stdClass();
@@ -222,6 +231,15 @@ class mod_assign_privacy_testcase extends provider_testcase {
         // Check feedback.
         $this->assertContains($teachercommenttext, $writer->get_data(['attempt 1', 'Feedback comments'])->commenttext);
         $this->assertContains($teachercommenttext2, $writer->get_data(['attempt 2', 'Feedback comments'])->commenttext);
+
+        // Check override data was exported correctly.
+        $overrideexport = $writer->get_data(['Overrides']);
+        $this->assertEquals(\core_privacy\local\request\transform::datetime($overridedata->duedate),
+                $overrideexport->duedate);
+        $this->assertEquals(\core_privacy\local\request\transform::datetime($overridedata->cutoffdate),
+                $overrideexport->cutoffdate);
+        $this->assertEquals(\core_privacy\local\request\transform::datetime($overridedata->allowsubmissionsfromdate),
+                $overrideexport->allowsubmissionsfromdate);
     }
 
     /**