mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 03:16:42 +02:00
MDL-62790 course: cap check in core_course_get_categories
This commit is contained in:
parent
25a592ff5f
commit
d80533be40
2 changed files with 6 additions and 9 deletions
|
@ -201,6 +201,7 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
|||
// Set the required capabilities by the external function.
|
||||
$context = context_system::instance();
|
||||
$roleid = $this->assignUserCapability('moodle/category:manage', $context->id);
|
||||
$this->assignUserCapability('moodle/category:viewhiddencategories', $context->id, $roleid);
|
||||
|
||||
// Retrieve category1 + sub-categories except not visible ones
|
||||
$categories = core_course_external::get_categories(array(
|
||||
|
@ -278,10 +279,10 @@ class core_course_externallib_testcase extends externallib_advanced_testcase {
|
|||
|
||||
$this->assertEquals($DB->count_records('course_categories'), count($categories));
|
||||
|
||||
$this->unassignUserCapability('moodle/category:manage', $context->id, $roleid);
|
||||
$this->unassignUserCapability('moodle/category:viewhiddencategories', $context->id, $roleid);
|
||||
|
||||
// Ensure maxdepthcategory is 2 and retrieve all categories without category:manage capability. It should retrieve all
|
||||
// visible categories as well.
|
||||
// Ensure maxdepthcategory is 2 and retrieve all categories without category:viewhiddencategories capability.
|
||||
// It should retrieve all visible categories as well.
|
||||
set_config('maxcategorydepth', 2);
|
||||
$categories = core_course_external::get_categories();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue