MDL-39536 completion: Unit tests for get_activities and has_activities
This commit is contained in:
@@ -514,31 +514,6 @@ WHERE
|
||||
$c->internal_set_data($cm, $data);
|
||||
}
|
||||
|
||||
function test_get_activities() {
|
||||
global $DB;
|
||||
|
||||
$c = new completion_info((object)array('id'=>42));
|
||||
|
||||
// Try with no activities
|
||||
$DB->expects($this->at(0))
|
||||
->method('get_records_select')
|
||||
->with('course_modules', 'course=42 AND completion<>'.COMPLETION_TRACKING_NONE)
|
||||
->will($this->returnValue(array()));
|
||||
$result = $c->get_activities();
|
||||
$this->assertEquals(array(), $result);
|
||||
|
||||
// Try with an activity (need to fake up modinfo for it as well)
|
||||
$DB->expects($this->at(0))
|
||||
->method('get_records_select')
|
||||
->with('course_modules', 'course=42 AND completion<>'.COMPLETION_TRACKING_NONE)
|
||||
->will($this->returnValue(array(13=>(object)array('id'=>13))));
|
||||
$modinfo = new stdClass;
|
||||
$modinfo->sections = array(array(1, 2, 3), array(12, 13, 14));
|
||||
$modinfo->cms[13] = (object)array('modname'=>'frog', 'name'=>'kermit');
|
||||
$result = $c->get_activities($modinfo);
|
||||
$this->assertEquals(array(13=>(object)array('id'=>13, 'modname'=>'frog', 'name'=>'kermit')), $result);
|
||||
}
|
||||
|
||||
// get_tracked_users() cannot easily be tested because it uses
|
||||
// get_role_users, so skipping that
|
||||
|
||||
|
||||
Reference in New Issue
Block a user