MDL-69253 mod_quiz: unit test for the last commit
authorTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 4 Aug 2020 13:00:30 +0000 (14:00 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 4 Aug 2020 13:50:57 +0000 (14:50 +0100)
mod/quiz/tests/generator_test.php

index 4ae705a..94e7ca7 100644 (file)
@@ -49,7 +49,8 @@ class mod_quiz_generator_testcase extends advanced_testcase {
 
         $generator->create_instance(array('course'=>$SITE->id));
         $generator->create_instance(array('course'=>$SITE->id));
-        $quiz = $generator->create_instance(array('course'=>$SITE->id));
+        $createtime = time();
+        $quiz = $generator->create_instance(array('course' => $SITE->id, 'timecreated' => 0));
         $this->assertEquals(3, $DB->count_records('quiz'));
 
         $cm = get_coursemodule_from_instance('quiz', $quiz->id);
@@ -59,5 +60,8 @@ class mod_quiz_generator_testcase extends advanced_testcase {
 
         $context = context_module::instance($cm->id);
         $this->assertEquals($quiz->cmid, $context->instanceid);
+
+        $this->assertEqualsWithDelta($createtime,
+                $DB->get_field('quiz', 'timecreated', ['id' => $cm->instance]), 2);
     }
 }