+
+ $this->switch_to_test_db(); // Switch to test DB for all the execution
+
+ $this->fill_records();
+
+ // Ignore any frontpageroleid, that would require to crete more contexts
+ $this->originaldefaultfrontpageroleid = $CFG->defaultfrontpageroleid;
+ $CFG->defaultfrontpageroleid = null;
+ }
+
+ public function tearDown() {
+ global $CFG;
+ // Recover original frontpageroleid
+ $CFG->defaultfrontpageroleid = $this->originaldefaultfrontpageroleid;
+ parent::tearDown();
+ }
+
+ private function fill_records() {
+ global $DB;
+
+ // Set up systcontext in the test database.
+ $this->syscontext->id = $this->testdb->insert_record('context', $this->syscontext);
+
+ // Add the capabilities used by ratings
+ foreach ($this->neededcaps as $neededcap) {
+ $this->testdb->insert_record('capabilities', (object)array('name' => 'moodle/rating:' . $neededcap,
+ 'contextlevel' => CONTEXT_COURSE));
+ }