MDL-40830 Clear course cache in mod_assign generator
authorMarina Glancy <marina@moodle.com>
Wed, 14 Aug 2013 02:37:24 +0000 (12:37 +1000)
committerMarina Glancy <marina@moodle.com>
Thu, 15 Aug 2013 11:44:05 +0000 (21:44 +1000)
mod/assign/tests/generator/lib.php
mod/assign/tests/lib_test.php

index ffe9b6a..126f43c 100644 (file)
@@ -78,6 +78,7 @@ class mod_assign_generator extends testing_module_generator {
 
         $record->coursemodule = $this->precreate_course_module($record->course, $options);
         $id = assign_add_instance($record, null);
+        rebuild_course_cache($record->course, true);
         return $this->post_add_instance($id, $record->coursemodule);
     }
 }
index 420a22f..304adc2 100644 (file)
@@ -40,23 +40,26 @@ require_once($CFG->dirroot . '/mod/assign/tests/base_test.php');
 class mod_assign_lib_testcase extends mod_assign_base_testcase {
 
     public function test_assign_print_overview() {
+        global $DB;
         $this->setUser($this->editingteachers[0]);
         $this->create_instance();
         $this->create_instance(array('duedate'=>time()));
 
+        $courses = $DB->get_records('course', array('id' => $this->course->id));
+
         $this->setUser($this->students[0]);
         $overview = array();
-        assign_print_overview(array($this->course->id => $this->course), $overview);
+        assign_print_overview($courses, $overview);
         $this->assertEquals(count($overview), 1);
 
         $this->setUser($this->teachers[0]);
         $overview = array();
-        assign_print_overview(array($this->course->id => $this->course), $overview);
+        assign_print_overview($courses, $overview);
         $this->assertEquals(count($overview), 1);
 
         $this->setUser($this->editingteachers[0]);
         $overview = array();
-        assign_print_overview(array($this->course->id => $this->course), $overview);
+        assign_print_overview($courses, $overview);
         $this->assertEquals(1, count($overview));
     }