public function is_enrolled($courseid) {
        if ($this->enrolledcourses === null || PHPUNIT_TEST) {
            // Since get_file_browser() returns a statically cached object we can't rely on cache
            // inside the file_browser class in the unittests.
            // TODO MDL-59964 remove this caching when it's implemented inside enrol_get_my_courses().
            $this->enrolledcourses = enrol_get_my_courses(['id']);
        }
        return array_key_exists($courseid, $this->enrolledcourses);
    }