Merge branch 'MDL-87657-501' of https://github.com/paulholden/moodle into MOODLE_501_STABLE
This commit is contained in:
@@ -363,7 +363,7 @@ function cohort_can_view_cohort($cohortorid, $currentcontext) {
|
||||
$cohort = $cohortorid;
|
||||
}
|
||||
|
||||
if ($cohort && in_array($cohort->contextid, $currentcontext->get_parent_context_ids())) {
|
||||
if ($cohort && in_array($cohort->contextid, $currentcontext->get_parent_context_ids(true))) {
|
||||
if ($cohort->visible) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -943,6 +943,21 @@ final class lib_test extends \advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether user can view cohort
|
||||
*
|
||||
* @covers ::cohort_can_view_cohort
|
||||
*/
|
||||
public function test_cohort_can_view_cohort(): void {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$context = \context_system::instance();
|
||||
$cohort = $this->getDataGenerator()->create_cohort(['contextid' => $context->id]);
|
||||
|
||||
$this->assertTrue(cohort_can_view_cohort($cohort, $context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the behaviour of cohort_get_cohort().
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user