MDL-40830 Clear course cache in mod_assign generator

This commit is contained in:
Marina Glancy 2013-08-14 12:37:24 +10:00
parent 838d78a9ff
commit 0e4954ecff
2 changed files with 7 additions and 3 deletions

View 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);
}
}

View 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));
}