Permalink
Browse files

MDL-38145 conditionlib_test calls API functions to create course and …

…category
  • Loading branch information...
1 parent f29e62c commit 592f476b02e9ddc7e33dff9524f565b986c44b71 @marinaglancy marinaglancy committed Feb 21, 2013
Showing with 12 additions and 11 deletions.
  1. +12 −11 lib/tests/conditionlib_test.php
@@ -181,13 +181,14 @@ public function test_section_constructor() {
}
private function make_course() {
- global $DB;
- $categoryid = $DB->insert_record('course_categories', (object)array('name'=>'conditionlibtest'));
- $courseid = $DB->insert_record('course', (object)array(
- 'fullname'=>'Condition test','shortname'=>'CT1',
- 'category'=>$categoryid,'enablecompletion'=>1));
- context_course::instance($courseid);
- return $courseid;
+ $category = $this->getDataGenerator()->create_category(array('name' => 'conditionlibtest'));
+ $course = $this->getDataGenerator()->create_course(
+ array('fullname' => 'Condition test',
+ 'shortname' => 'CT1',
+ 'category' => $category->id,
+ 'enablecompletion' => 1));
+ context_course::instance($course->id);
+ return $course->id;
}
private function make_course_module($courseid,$params=array()) {
@@ -253,7 +254,7 @@ function test_modinfo() {
'completion'=>COMPLETION_TRACKING_MANUAL));
$cmid2=$this->make_course_module($courseid,array(
'showavailability'=>0,'availablefrom'=>0,'availableuntil'=>0));
- $this->make_section($courseid,array($cmid1,$cmid2));
+ $this->make_section($courseid, array($cmid1, $cmid2), 1);
// Add a fake grade item
$gradeitemid=$DB->insert_record('grade_items',(object)array(
@@ -351,7 +352,7 @@ function test_add_and_remove() {
$courseid=$this->make_course();
$cmid=$this->make_course_module($courseid,array(
'showavailability'=>0,'availablefrom'=>0,'availableuntil'=>0));
- $this->make_section($courseid,array($cmid));
+ $this->make_section($courseid, array($cmid), 1);
// Check it has no conditions
$test1=new condition_info((object)array('id'=>$cmid),
@@ -394,7 +395,7 @@ public function test_section_add_and_remove() {
// Make course and module
$courseid = $this->make_course();
$cmid = $this->make_course_module($courseid);
- $sectionid = $this->make_section($courseid, array($cmid));
+ $sectionid = $this->make_section($courseid, array($cmid), 1);
// Check it has no conditions
$test1 = new condition_info_section((object)array('id'=>$sectionid),
@@ -468,7 +469,7 @@ function test_is_available() {
// Completion
$oldid=$cmid;
$cmid=$this->make_course_module($courseid);
- $this->make_section($courseid,array($oldid,$cmid));
+ $this->make_section($courseid, array($oldid, $cmid), 1);
$oldcm=$DB->get_record('course_modules',array('id'=>$oldid));
$oldcm->completion=COMPLETION_TRACKING_MANUAL;
$DB->update_record('course_modules',$oldcm);

0 comments on commit 592f476

Please sign in to comment.