From 7a3e11d5b5eb3eefbc8cf2e55e985ece681a8f11 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Thu, 21 Feb 2013 11:50:45 +1100 Subject: [PATCH] MDL-38144 categories are created in reverse sort order in externallib --- course/externallib.php | 1 - course/tests/externallib_test.php | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/course/externallib.php b/course/externallib.php index 1d91b94313f..88c0693048e 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -1254,7 +1254,6 @@ class core_course_external extends external_api { $newcategory = new stdClass(); $newcategory->name = $category['name']; $newcategory->parent = $category['parent']; - $newcategory->sortorder = 999; // Same as in the course/editcategory.php . // Format the description. if (!empty($category['description'])) { $newcategory->description = $category['description']; diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index 1eb755ed70f..dac68374803 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -111,8 +111,12 @@ class core_course_external_testcase extends externallib_advanced_testcase { $category2 = $DB->get_record('course_categories', array('id' => $category2->id)); $category3 = $DB->get_record('course_categories', array('id' => $category3->id)); - $this->assertGreaterThanOrEqual($category1->sortorder, $category3->sortorder); - $this->assertGreaterThanOrEqual($category2->sortorder, $category3->sortorder); + // sortorder sequence (and sortorder) must be: + // category 1 + // category 3 + // category 2 + $this->assertGreaterThan($category1->sortorder, $category3->sortorder); + $this->assertGreaterThan($category3->sortorder, $category2->sortorder); // Call without required capability $this->unassignUserCapability('moodle/category:manage', $contextid, $roleid);