Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
.
/**
* Unit tests for core\content class.
*
* @package core
* @category test
* @copyright 2020 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core;
/**
* Unit tests for core\content class.
*
* @package core
* @category test
* @copyright 2020 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content_test extends \advanced_testcase {
/**
* A test to confirm only valid cases allow exporting of course content.
*/
public function test_can_export_context_course() {
global $DB;
$this->resetAfterTest();
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$course1context = \context_course::instance($course1->id);
$course2context = \context_course::instance($course2->id);
// Enrol user as student in course1 only.
$user = $this->getDataGenerator()->create_and_enrol($course1, 'student');
// Confirm by default enrolled user does not have permission to export in course1.
$this->assertFalse(content::can_export_context($course1context, $user));
// Make course download available on site, but not enabled in course1 or by default.
set_config('downloadcoursecontentallowed', true);
// Confirm user still does not have permission to export (disabled in courses by default).
$this->assertFalse(content::can_export_context($course1context, $user));
// Enable export in courses by default.
set_config('downloadcontentsitedefault', DOWNLOAD_COURSE_CONTENT_ENABLED, 'moodlecourse');
// Confirm user now has permission to export in course1 only.
$this->assertTrue(content::can_export_context($course1context, $user));
// Disable course downloads in course1.
$course1->downloadcontent = DOWNLOAD_COURSE_CONTENT_DISABLED;
$DB->update_record('course', $course1);
rebuild_course_cache($course1->id);
// Confirm user does not have permission to export in course1.
$this->assertFalse(content::can_export_context($course1context, $user));
// Enable course downloads in course1.
$course1->downloadcontent = DOWNLOAD_COURSE_CONTENT_ENABLED;
$DB->update_record('course', $course1);
rebuild_course_cache($course1->id);
// Confirm user has permission to export in course1.
$this->assertTrue(content::can_export_context($course1context, $user));
// Confirm user does not have permission to export in course they are not enrolled in (course2).
$this->assertFalse(content::can_export_context($course2context, $user));
// Disable export in courses by default.
set_config('downloadcontentsitedefault', DOWNLOAD_COURSE_CONTENT_DISABLED, 'moodlecourse');
// Confirm user still has permission to export in course1 (still enabled at the course level).
$this->assertTrue(content::can_export_context($course1context, $user));
// Disable the course downloads feature.
set_config('downloadcoursecontentallowed', false);
// Confirm user no longer has permission to export in course1.
$this->assertFalse(content::can_export_context($course1context, $user));
}
/**
* A test to confirm unsupported contexts will return false when checking whether content can be exported.
*/
public function test_can_export_context_unsupported_context() {
$this->resetAfterTest();
$course1 = $this->getDataGenerator()->create_course();
$systemcontext = \context_system::instance();
// Enrol user as student in course1 only.
$user = $this->getDataGenerator()->create_and_enrol($course1, 'student');
// Make course download available on site (course context).
set_config('downloadcoursecontentallowed', true);
// Confirm system context does not gain permission to export content.
$this->assertFalse(content::can_export_context($systemcontext, $user));
}
}