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 310 and 403] [Versions 311 and 403] [Versions 39 and 403]

(no description)

File Size: 1627 lines (76 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 search/tests/fixtures/testable_core_search.php
 search/tests/fixtures/mock_search_area.php

Defines 2 classes


Class: manager_test  - X-Ref

Unit tests for search manager.

setUp()   X-Ref
Courses area id.


tearDown()   X-Ref
No description

test_search_enabled()   X-Ref
No description

test_course_search_url(?bool $gsenabled, ?bool $allcourses, ?bool $enablearea, string $expected)   X-Ref
Tests the course search url is correct.

param: bool|null $gsenabled Enable global search (null to leave as the default).
param: bool|null $allcourses Enable searching all courses (null to leave as the default).
param: bool|null $enablearea Enable the course search area (null to leave as the default).
param: string $expected The expected course search url.

data_course_search_url()   X-Ref
Data for the test_course_search_url test.

return: array[]

test_can_replace_course_search(?bool $gsenabled, ?bool $allcourses, ?bool $enablearea, bool $expected)   X-Ref
Tests that we detect that global search can replace frontpage course search.

param: bool|null $gsenabled Enable global search (null to leave as the default).
param: bool|null $allcourses Enable searching all courses (null to leave as the default).
param: bool|null $enablearea Enable the course search area (null to leave as the default).
param: bool $expected The expected result.

data_can_replace_course_search()   X-Ref
Data for the test_can_replace_course_search test.

return: array[]

test_search_areas()   X-Ref
No description

test_search_config()   X-Ref
No description

test_get_last_indexing_duration()   X-Ref
Tests the get_last_indexing_duration method in the base area class.


test_partial_indexing()   X-Ref
Tests that partial indexing works correctly.


test_index_progress()   X-Ref
Tests the progress display while indexing.

This tests the different logic about displaying progress for slow/fast and
complete/incomplete processing.

test_future_documents()   X-Ref
Tests that documents with modified time in the future are NOT indexed (as this would cause
a problem by preventing it from indexing other documents modified between now and the future
date).


test_context_indexing()   X-Ref
Tests that indexing a specified context works correctly.


test_search_user_accesses()   X-Ref
Adding this test here as get_areas_user_accesses process is the same, results just depend on the context level.

return: void

test_search_user_accesses_blocks()   X-Ref
Tests the block support in get_search_user_accesses.

return: void

test_search_users_accesses_limit_non_enrolled_course()   X-Ref
Tests retrieval of users search areas when limiting to a course the user is not enrolled in


test_search_user_accesses_allavailable()   X-Ref
Test get_areas_user_accesses with regard to the 'all available courses' config option.

return: void

test_search_user_accesses_groups()   X-Ref
Tests group-related aspects of the get_areas_user_accesses function.


test_is_search_area()   X-Ref
test_is_search_area

return: void

test_request_index()   X-Ref
Tests the request_index function used for reindexing certain contexts. This only tests
adding things to the request list, it doesn't test that they are actually indexed by the
scheduled task.


test_process_index_requests()   X-Ref
Tests the process_index_requests function.


test_get_search_area_categories()   X-Ref
Test search area categories.


test_is_search_area_categories_enabled()   X-Ref
Test that we can find out if search area categories functionality is enabled.


test_should_hide_all_results_category()   X-Ref
Test that we can find out if hiding all results category is enabled.


test_get_default_area_category_name()   X-Ref
Test that we can get default search category name.


test_get_search_area_category_by_name()   X-Ref
Test that we can get correct search area category by its name.


test_include_all_courses_enabled()   X-Ref
Test that we can check that "Include all visible courses" feature is enabled.


test_build_limitcourseids()   X-Ref
Test that we can correctly build a list of courses for a course filter for the search results.


parse_search_area_id_data_provider()   X-Ref
Test data for test_parse_areaid test fucntion.

return: array

test_parse_search_area_id($areaid, $expected)   X-Ref
Test that manager class can parse area id correctly.

param: string $areaid Area id to parse.
param: array $expected Expected result of parsing.

test_parse_invalid_search_area_id()   X-Ref
Test that manager class will throw an exception when parsing an invalid area id.


test_cleaning_up_existing_search_area()   X-Ref
Test getting a coding exception when trying to lean up existing search area.


Class: to  - X-Ref

test_clean_up_non_existing_search_area()   X-Ref
Test clean up of non existing search area.


test_context_deletion()   X-Ref
Tests the context_deleted, course_deleting_start, and course_deleting_finish methods.