Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Class: tree_test  - X-Ref

Unit tests for the condition tree class and related logic.

setUp()   X-Ref
No description

test_construct_errors()   X-Ref
Tests constructing a tree with errors.


test_construct_ignore_missing_plugin()   X-Ref
Tests constructing a tree with plugin that does not exist (ignored).


test_construct_just_trees()   X-Ref
Tests constructing a tree with subtrees using all available operators.


test_construct_with_mock_plugin()   X-Ref
Tests constructing tree using the mock plugin.


test_check_available()   X-Ref
Tests the check_available and get_result_information functions.


get_available_results($structure, \core_availability\info $info, $userid)   X-Ref
Shortcut function to check availability and also get information.

param: \stdClass $structure Tree structure
param: \core_availability\info $info Location info
param: int $userid User id

render_full_information($structure, \core_availability\info $info)   X-Ref
Shortcut function to render the full availability information.

param: \stdClass $structure Tree structure
param: \core_availability\info $info Location info

test_is_available_for_all()   X-Ref
Tests the is_available_for_all() function.


test_get_full_information()   X-Ref
Tests the get_full_information() function.


test_is_empty()   X-Ref
Tests the is_empty() function.


test_get_all_children()   X-Ref
Tests the get_all_children() function.


test_update_dependency_id()   X-Ref
Tests the update_dependency_id() function.


test_filter_users()   X-Ref
Tests the filter_users function.


test_get_json()   X-Ref
Tests the get_json methods in tree (which are mainly for use in testing
but might be used elsewhere).


test_unique_sql_parameter_behaviour()   X-Ref
Tests the behaviour of the counter in unique_sql_parameter().

There was a problem with static counters used to implement a sequence of
parameter placeholders (MDL-53481). As always with static variables, it
is a bit tricky to unit test the behaviour reliably as it depends on the
actual tests executed and also their order.

To minimise risk of false expected behaviour, this test method should be
first one where {@link core_availability\tree::get_user_list_sql()} is
used. We also use higher number of condition instances to increase the
risk of the counter collision, should there remain a problem.

test_get_user_list_sql()   X-Ref
Tests get_user_list_sql.


mock(array $params)   X-Ref
Utility function to build the PHP structure representing a mock condition.

param: array $params Mock parameters
return: \stdClass Structure object