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

/**
 * Tests for helper.
 *
 * @package    tool_usertours
 * @category   test
 * @copyright  2022 Huong Nguyen <huongnv13@gmail.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @covers \tool_usertours\helper
 * @covers \tool_usertours\hook\before_serverside_filter_fetch
 * @covers \tool_usertours\hook\before_clientside_filter_fetch
 */
final class helper_test extends \advanced_testcase {
    /**
     * Data Provider for get_string_from_input.
     *
     * @return array
     */
    public static function get_string_from_input_provider(): array {
        return [
            'Text'  => [
                'example',
                'example',
            ],
            'Text which looks like a langstring' => [
                'example,fakecomponent',
                'example,fakecomponent',
            ],
            'Text which is a langstring' => [
                'administration,core',
                'Administration',
            ],
            'Text which is a langstring but uses "moodle" instead of "core"' => [
                'administration,moodle',
                'Administration',
            ],
            'Text which is a langstring, but with extra whitespace' => [
                '  administration,moodle  ',
                'Administration',
            ],
            'Looks like a langstring, but has incorrect space around comma' => [
                'administration , moodle',
                'administration , moodle',
            ],
        ];
    }

    /**
     * Ensure that the get_string_from_input function returns langstring strings correctly.
     *
     * @dataProvider get_string_from_input_provider
     * @param string $string The string to test
     * @param string $expected The expected result
     */
    public function test_get_string_from_input($string, $expected): void {
        $this->assertEquals($expected, helper::get_string_from_input($string));
    }

    public function test_get_all_filters(): void {
        $filters = helper::get_all_filters();
        $this->assertIsArray($filters);

        array_map(
            function ($filter) {
                $this->assertIsString($filter);
                $this->assertTrue(class_exists($filter));
                $this->assertTrue(is_a($filter, \tool_usertours\local\filter\base::class, true));
                $rc = new \ReflectionClass($filter);
                $this->assertTrue($rc->isInstantiable());
            },
            $filters,
        );

        $this->assertNotContains(\tool_usertours\test\hook\serverside_filter_fixture::class, $filters);
        $this->assertNotContains(\tool_usertours\test\hook\clientside_filter_fixture::class, $filters);
        $this->assertContains(\tool_usertours\local\filter\accessdate::class, $filters);
        $this->assertContains(\tool_usertours\local\clientside_filter\cssselector::class, $filters);

        $filters = helper::get_all_clientside_filters();
        array_map(
            function ($filter) {
                $this->assertIsString($filter);
            },
            $filters,
        );
    }

    public function test_get_invalid_server_filter(): void {
        \core\di::set(
            \core\hook\manager::class,
            \core\hook\manager::phpunit_get_instance([
                'test_plugin1' => self::get_fixture_path(__NAMESPACE__, 'invalid_serverside_hook_fixture.php'),
            ]),
        );

        $this->expectException(\coding_exception::class);
        helper::get_all_filters();
    }

    public function test_clientside_filter_for_serverside_hook(): void {
        \core\di::set(
            \core\hook\manager::class,
            \core\hook\manager::phpunit_get_instance([
                'test_plugin1' => self::get_fixture_path(__NAMESPACE__, 'clientside_filter_for_serverside_hook.php'),
            ]),
        );

        $this->expectException(\coding_exception::class);
        helper::get_all_filters();
    }

    public function test_serverside_filter_for_clientside_hook(): void {
        \core\di::set(
            \core\hook\manager::class,
            \core\hook\manager::phpunit_get_instance([
                'test_plugin1' => self::get_fixture_path(__NAMESPACE__, 'serverside_filter_for_clientside_hook.php'),
            ]),
        );

        $this->expectException(\coding_exception::class);
        helper::get_all_clientside_filters();
    }

    public function test_filter_hooks(): void {
        \core\di::set(
            \core\hook\manager::class,
            \core\hook\manager::phpunit_get_instance([
                'test_plugin1' => self::get_fixture_path(__NAMESPACE__, 'hook_fixtures.php'),
            ]),
        );

        $filters = helper::get_all_filters();
        $this->assertIsArray($filters);

        // Check the modifications from the serverside hook.
        $this->assertContains(\tool_usertours\test\hook\serverside_filter_fixture::class, $filters);
        $this->assertNotContains(\tool_usertours\test\hook\another_clientside_filter_fixture::class, $filters);
        $this->assertNotContains(\tool_usertours\local\filter\accessdate::class, $filters);

        // Check the modifications from the clientside hook.
        $this->assertContains(\tool_usertours\test\hook\clientside_filter_fixture::class, $filters);
        $this->assertNotContains(\tool_usertours\test\hook\another_serverside_filter_fixture::class, $filters);
        $this->assertNotContains(\tool_usertours\local\clientside_filter\cssselector::class, $filters);

        array_map(
            function ($filter) {
                $this->assertIsString($filter);
                $this->assertTrue(class_exists($filter));
                $this->assertTrue(is_a($filter, \tool_usertours\local\filter\base::class, true));
                $rc = new \ReflectionClass($filter);
                $this->assertTrue($rc->isInstantiable());
            },
            $filters,
        );
    }

    public function test_get_clientside_filter_module_names(): void {
        \core\di::set(
            \core\hook\manager::class,
            \core\hook\manager::phpunit_get_instance([
                'test_plugin1' => self::get_fixture_path(__NAMESPACE__, 'invalid_clientside_hook_fixture.php'),
            ]),
        );

        $filters = helper::get_all_clientside_filters();

        $this->expectException(\coding_exception::class);
        $this->expectExceptionMessageMatches('/Could not determine component/');
        helper::get_clientside_filter_module_names($filters);
    }
}

Filemanager

Name Type Size Permission Actions
behat Folder 0777
fixtures Folder 0777
privacy Folder 0777
accessdate_filter_test.php File 5.54 KB 0777
cache_test.php File 12.29 KB 0777
helper_test.php File 7.09 KB 0777
helper_trait.php File 2.95 KB 0777
manager_test.php File 11.03 KB 0777
role_filter_test.php File 9.55 KB 0777
step_test.php File 22.91 KB 0777
theme_filter_test.php File 2.93 KB 0777
tour_test.php File 31.67 KB 0777
Filemanager