Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 39 and 403]

Core search class adapted to unit test.

Copyright: 2015 David Monllao {@link http://www.davidmonllao.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 135 lines (4 kb)
Included or required: 6 times
Referenced: 21 times
Includes or requires: 1 file
 search/tests/fixtures/mock_search_engine.php

Defines 1 class

testable_core_search:: (7 methods):
  instance()
  get_areas_user_accesses()
  add_search_area()
  add_core_search_areas()
  is_search_area()
  fake_current_time()
  build_limitcourseids()


Class: testable_core_search  - X-Ref

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.

instance($searchengine = false, bool $ignored = false)   X-Ref
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

get_areas_user_accesses($limitcourseids = false, $limitcontextids = false)   X-Ref
Changes visibility.

return: array

add_search_area($areaid, \core_search\base $searcharea)   X-Ref
Adds an enabled search component to the search areas list.

param: string $areaid
param: \core_search\base $searcharea
return: void

add_core_search_areas()   X-Ref
Loads all core search areas.

return: void

is_search_area($classname)   X-Ref
Changes visibility.

param: string $classname
return: bool

fake_current_time($faketime = 0.0)   X-Ref
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

build_limitcourseids(\stdClass $formdata)   X-Ref
Makes build_limitcourseids method public for testing.

param: \stdClass $formdata Submitted search form data.
return: array|bool