MDL-44725 workshop: correct module generation in unittests (15)

This commit is contained in:
Marina Glancy
2014-09-02 13:03:37 +01:00
committed by sam marshall
parent 002ccdcf49
commit ed2ecd3e35
6 changed files with 45 additions and 32 deletions
+12 -15
View File
@@ -196,22 +196,19 @@ class workshop {
}
}
if (is_null($cm) || is_null($course)) {
if (!PHPUNIT_TEST) {
throw new coding_exception('Must specify $cm and $course');
}
throw new coding_exception('Must specify $cm and $course');
}
$this->course = $course;
if ($cm instanceof cm_info) {
$this->cm = $cm;
} else {
$this->course = $course;
if ($cm instanceof cm_info) {
$this->cm = $cm;
} else {
$modinfo = get_fast_modinfo($course);
$this->cm = $modinfo->get_cm($cm->id);
}
if (is_null($context)) {
$this->context = context_module::instance($this->cm->id);
} else {
$this->context = $context;
}
$modinfo = get_fast_modinfo($course);
$this->cm = $modinfo->get_cm($cm->id);
}
if (is_null($context)) {
$this->context = context_module::instance($this->cm->id);
} else {
$this->context = $context;
}
}