mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Unit tests MDL-24976 Fixed conditionlib unit test (also added thing to ensure that debug warning in conditionlib is shown in unit test if applicable)
This commit is contained in:
parent
7f91ba532b
commit
72d021a927
2 changed files with 11 additions and 4 deletions
|
@ -396,8 +396,8 @@ WHERE
|
|||
$modinfo = get_fast_modinfo($course);
|
||||
}
|
||||
if (empty($modinfo->cms[$cmid])) {
|
||||
global $PAGE;
|
||||
if (isset($PAGE) && strpos($PAGE->pagetype, 'course-view-')===0) {
|
||||
global $PAGE, $UNITTEST;
|
||||
if (!empty($UNITTEST) || (isset($PAGE) && strpos($PAGE->pagetype, 'course-view-')===0)) {
|
||||
debugging("Warning: activity {$this->cm->id} '{$this->cm->name}' has condition on deleted activity $cmid (to get rid of this message, edit the named activity)");
|
||||
}
|
||||
continue;
|
||||
|
|
|
@ -10,7 +10,7 @@ class conditionlib_test extends UnitTestCaseUsingDatabase {
|
|||
|
||||
public $conditionlib_tables = array(
|
||||
'lib' => array(
|
||||
'context', 'capabilities', 'role',
|
||||
'files','context', 'capabilities', 'role',
|
||||
'role_capabilities', 'role_assignments',
|
||||
'course_categories', 'course',
|
||||
'modules',
|
||||
|
@ -287,11 +287,18 @@ class conditionlib_test extends UnitTestCaseUsingDatabase {
|
|||
$oldcm->completion=COMPLETION_TRACKING_MANUAL;
|
||||
$DB->update_record('course_modules',$oldcm);
|
||||
|
||||
// Need to reset modinfo after changing the options
|
||||
rebuild_course_cache($courseid);
|
||||
$reset = 'reset';
|
||||
get_fast_modinfo($reset);
|
||||
|
||||
$ci=new condition_info((object)array('id'=>$cmid),CONDITION_MISSING_EVERYTHING);
|
||||
$ci->add_completion_condition($oldid,COMPLETION_COMPLETE);
|
||||
condition_info::wipe_session_cache();
|
||||
|
||||
$this->assertFalse($ci->is_available($text,false));
|
||||
$this->assertEqual(get_string('requires_completion_1','condition','xxx'),$text);
|
||||
|
||||
completion_info::wipe_session_cache();
|
||||
$completion=new completion_info($DB->get_record('course',array('id'=>$courseid)));
|
||||
$completion->update_state($oldcm,COMPLETION_COMPLETE);
|
||||
completion_info::wipe_session_cache();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue