Skip to content
Browse files

MDL-37476 course_create unit test fails if course completion is enabled

  • Loading branch information...
1 parent a5ec499 commit 821676f5b7a94a49139535f9b68a7b7afda46f1a @mouneyrac mouneyrac committed
Showing with 8 additions and 9 deletions.
  1. +8 −9 course/tests/externallib_test.php
View
17 course/tests/externallib_test.php
@@ -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);
@@ -367,7 +370,7 @@ 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);
@@ -375,7 +378,7 @@ public function test_create_courses() {
$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) {
@@ -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');

0 comments on commit 821676f

Please sign in to comment.
Something went wrong with that request. Please try again.