Skip to content

Commit

Permalink
Merge branch 'MDL-37476-master' of git://github.com/mouneyrac/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Jan 29, 2013
2 parents ab58c6b + 821676f commit da810f5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions course/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ public function test_create_courses() {

$this->resetAfterTest(true);

// Enable course completion.
set_config('enablecompletion', 1);

// Set the required capabilities by the external function
$contextid = context_system::instance()->id;
$roleid = $this->assignUserCapability('moodle/course:create', $contextid);
Expand Down Expand Up @@ -367,15 +370,15 @@ public function test_create_courses() {
foreach ($course3options as $key => $value) {
$course3['courseformatoptions'][] = array('name' => $key, 'value' => $value);
}
$courses = array($course1, $course2);
$courses = array($course1, $course2, $course3);

$createdcourses = core_course_external::create_courses($courses);

// We need to execute the return values cleaning process to simulate the web service server.
$createdcourses = external_api::clean_returnvalue(core_course_external::create_courses_returns(), $createdcourses);

// Check that right number of courses were created.
$this->assertEquals(2, count($createdcourses));
$this->assertEquals(3, count($createdcourses));

// Check that the courses were correctly created.
foreach ($createdcourses as $createdcourse) {
Expand Down Expand Up @@ -407,13 +410,9 @@ public function test_create_courses() {
$this->assertEquals($courseinfo->theme, $course2['forcetheme']);
}

if (completion_info::is_enabled_for_site()) {
$this->assertEquals($courseinfo->enablecompletion, $course2['enabledcompletion']);
$this->assertEquals($courseinfo->completionstartonenrol, $course2['completionstartonenrol']);
} else {
$this->assertEquals($courseinfo->enablecompletion, 0);
$this->assertEquals($courseinfo->completionstartonenrol, 0);
}
// We enabled completion at the beginning of the test.
$this->assertEquals($courseinfo->enablecompletion, $course2['enablecompletion']);
$this->assertEquals($courseinfo->completionstartonenrol, $course2['completionstartonenrol']);

} else if ($createdcourse['shortname'] == $course1['shortname']) {
$courseconfig = get_config('moodlecourse');
Expand Down

0 comments on commit da810f5

Please sign in to comment.