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

/**
 * Unit Tests for the approved contextlist Class
 *
 * @package     core_privacy
 * @category    test
 * @copyright   2018 Andrew Nicols <andrew@nicols.co.uk>
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

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

global $CFG;

use \core_privacy\local\request\contextlist;

/**
 * Tests for the \core_privacy API's approved contextlist functionality.
 *
 * @copyright   2018 Andrew Nicols <andrew@nicols.co.uk>
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @coversDefaultClass \core_privacy\local\request\contextlist
 */
final class contextlist_test extends advanced_testcase {

    /**
     * Ensure that valid SQL results in the relevant contexts being added.
     *
     * @covers ::add_from_sql
     */
    public function test_add_from_sql(): void {
        global $DB;

        $sql = "SELECT c.id FROM {context} c";
        $params = [];
        $allcontexts = $DB->get_records_sql($sql, $params);

        $uit = new contextlist();
        $uit->add_from_sql($sql, $params);

        $this->assertCount(count($allcontexts), $uit);
    }

    /**
     * Ensure that valid system context id is added.
     *
     * @covers ::add_system_context
     */
    public function test_add_system_context(): void {
        $cl = new contextlist();
        $cl->add_system_context();

        $this->assertCount(1, $cl);

        foreach ($cl->get_contexts() as $context) {
            $this->assertEquals(SYSCONTEXTID, $context->id);
        }
    }

    /**
     * Ensure that a valid user context id is added.
     *
     * @covers ::add_user_context
     */
    public function test_add_user_context(): void {
        $this->resetAfterTest();

        $user = $this->getDataGenerator()->create_user();
        $this->getDataGenerator()->create_user();

        $cl = new contextlist();
        $cl->add_user_context($user->id);

        $this->assertCount(1, $cl);

        foreach ($cl->get_contexts() as $context) {
            $this->assertEquals(\context_user::instance($user->id)->id, $context->id);
        }
    }

    /**
     * Ensure that valid user contexts are added.
     *
     * @covers ::add_user_contexts
     */
    public function test_add_user_contexts(): void {
        $this->resetAfterTest();

        $user1 = $this->getDataGenerator()->create_user();
        $user2 = $this->getDataGenerator()->create_user();
        $this->getDataGenerator()->create_user();

        $cl = new contextlist();
        $cl->add_user_contexts([$user1->id, $user2->id]);

        $this->assertCount(2, $cl);

        $contexts = $cl->get_contextids();
        $this->assertContainsEquals(\context_user::instance($user1->id)->id, $contexts);
        $this->assertContainsEquals(\context_user::instance($user2->id)->id, $contexts);
    }

    /**
     * Test {@link \core_privacy\local\request\contextlist::test_guess_id_field_from_sql()} implementation.
     *
     * @dataProvider data_guess_id_field_from_sql
     * @param string $sql Input SQL we try to extract the context id field name from.
     * @param string $expected Expected detected value.
     * @covers ::guess_id_field_from_sql
     */
    public function test_guess_id_field_from_sql($sql, $expected): void {

        $rc = new \ReflectionClass(contextlist::class);
        $rcm = $rc->getMethod('guess_id_field_from_sql');
        $actual = $rcm->invoke(new contextlist(), $sql);

        $this->assertEquals($expected, $actual, 'Unable to guess context id field in: '.$sql);
    }

    /**
     * Provides data sets for {@link self::test_guess_id_field_from_sql()}.
     *
     * @return array
     */
    public static function data_guess_id_field_from_sql(): array {
        return [
            'easy' => [
                'SELECT contextid FROM {foo}',
                'contextid',
            ],
            'with_distinct' => [
                'SELECT DISTINCT contextid FROM {foo}',
                'contextid',
            ],
            'with_dot' => [
                'SELECT cx.id FROM {foo} JOIN {context} cx ON blahblahblah',
                'id',
            ],
            'letter_case_does_not_matter' => [
                'Select ctxid From {foo} Where bar = ?',
                'ctxid',
            ],
            'alias' => [
                'SELECT foo.contextid AS ctx FROM {bar} JOIN {foo} ON bar.id = foo.barid',
                'ctx',
            ],
            'tabs' => [
                "SELECT\tctxid\t\tFROM foo f",
                'ctxid',
            ],
            'whitespace' => [
                "SELECT
                    ctxid\t
                   \tFROM foo f",
                'ctxid',
            ],
            'just_number' => [
                '1',
                '1',
            ],
            'select_number' => [
                'SELECT 2',
                '2',
            ],
            'select_number_with_semicolon' => [
                'SELECT 3;',
                '3',
            ],
            'select_number_from_table' => [
                'SELECT 4 FROM users',
                '4',
            ],
            'select_with_complex_subqueries' => [
                'SELECT id FROM table WHERE id IN (
                     SELECT x FROM xtable
                     UNION
                     SELECT y FROM (
                         SELECT y FROM ytable
                         JOIN ztable ON (z = y)))',
                'id'
            ],
            'invalid_union_with_first_being_column_name' => [
                'SELECT id FROM table UNION SELECT 1 FROM table',
                ''
            ],
            'invalid_union_with_first_being_numeric' => [
                'SELECT 1 FROM table UNION SELECT id FROM table',
                ''
            ],
            'invalid_union_without_from' => [
                'SELECT 1 UNION SELECT id FROM table',
                ''
            ],
            'invalid_1' => [
                'SELECT 1+1',
                '',
            ],
            'invalid_2' => [
                'muhehe',
                '',
            ],
        ];
    }
}

Filemanager

Name Type Size Permission Actions
fixtures Folder 0777
privacy Folder 0777
approved_contextlist_test.php File 2.17 KB 0777
approved_userlist_test.php File 3.43 KB 0777
collection_test.php File 6.93 KB 0777
contextlist_base_test.php File 9.06 KB 0777
contextlist_collection_test.php File 6.32 KB 0777
contextlist_test.php File 6.66 KB 0777
legacy_polyfill_test.php File 9.76 KB 0777
manager_test.php File 21.23 KB 0777
moodle_content_writer_test.php File 62.49 KB 0777
request_helper_test.php File 7.86 KB 0777
request_transform_test.php File 4.12 KB 0777
sitepolicy_test.php File 15.17 KB 0777
tests_content_writer_test.php File 21.25 KB 0777
types_database_table_test.php File 4.39 KB 0777
types_external_location_test.php File 4.41 KB 0777
types_plugintype_link_test.php File 3.43 KB 0777
types_subsystem_link_test.php File 3.43 KB 0777
types_user_preference_test.php File 3.28 KB 0777
userlist_base_test.php File 7.79 KB 0777
userlist_collection_test.php File 5.42 KB 0777
userlist_test.php File 2.96 KB 0777
writer_test.php File 3.37 KB 0777
Filemanager