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: secondary_test  - X-Ref

Class core_secondary_testcase

Unit test for the secondary nav view.

test_get_leaf_nodes(float $siteorder, float $courseorder, float $moduleorder)   X-Ref
Test the get_leaf_nodes function

param: float $siteorder The order for the siteadmin node
param: float $courseorder The order for the course node
param: float $moduleorder The order for the module node

leaf_nodes_order_provider()   X-Ref
Data provider for test_get_leaf_nodes

return: array

test_setting_initialise(string $context, string $expectedfirstnode,string $header, string $activenode, string $courseformat = 'topics')   X-Ref
Test the initialise in different contexts

param: string $context The context to setup for - course, module, system
param: string $expectedfirstnode The expected first node
param: string $header The expected string
param: string $activenode The expected active node
param: string $courseformat The used course format (only applicable in the course and module context).
return: void

setting_initialise_provider()   X-Ref
Data provider for the test_setting_initialise function

return: array

get_tree_initilised_to_set_activate(?string $seturl = null)   X-Ref
Get the nav tree initialised to test active_node_scan.

This is to test the secondary nav with navigation_node instance.

param: string|null $seturl The url set for $PAGE.
return: navigation_node The initialised nav tree.

test_active_node_scan(string $expectedkey, ?string $key = null, ?string $seturl = null)   X-Ref
Testing active_node_scan on navigation_node instance.

param: string $expectedkey The expected node key.
param: string|null $key The key set by user using set_secondary_active_tab.
param: string|null $seturl The url set by user.
return: void

active_node_scan_provider()   X-Ref
Data provider for the active_node_scan_provider

return: array

test_force_nodes_into_more_menu(array $secondarynavnodesdata, array $defaultmoremenunodes,?int $maxdisplayednodes, array $expecedmoremenunodes)   X-Ref
Test the force_nodes_into_more_menu method.

param: array $secondarynavnodesdata The array which contains the data used to generate the secondary navigation
param: array $defaultmoremenunodes  The array containing the keys of the navigation nodes which should be added
param: int|null $maxdisplayednodes  The maximum limit of navigation nodes displayed in the secondary navigation
param: array $expecedmoremenunodes  The array containing the keys of the expected navigation nodes which are

force_nodes_into_more_menu_provider()   X-Ref
Data provider for the test_force_nodes_into_more_menu function.

return: array

generate_node_tree_construct(array $structure, string $parentkey)   X-Ref
Recursive call to generate a navigation node given an array definition.

param: array $structure
param: string $parentkey
return: navigation_node

test_nodes_match_current_url(string $selectedurl, string $expectednode)   X-Ref
Test the nodes_match_current_url function.

param: string $selectedurl
param: string $expectednode

nodes_match_current_url_provider()   X-Ref
Provider for test_nodes_match_current_url

return: \string[][]

test_get_menu_array(string $selected, array $expected)   X-Ref
Test the get_menu_array function

param: string $selected
param: array $expected

get_menu_array_provider()   X-Ref
Provider for test_get_menu_array

return: array[]

test_get_node_with_first_action(string $selectedkey, ?string $expectedkey)   X-Ref
Test the get_node_with_first_action function

param: string $selectedkey
param: string|null $expectedkey

get_node_with_first_action_provider()   X-Ref
Provider for test_get_node_with_first_action

return: array

test_add_external_nodes_to_secondary(array $structure, array $expectednodes, bool $separatenode = false)   X-Ref
Test the add_external_nodes_to_secondary function.

param: array $structure The structure of the navigation node tree to setup with.
param: array $expectednodes The expected nodes added to the secondary navigation
param: bool $separatenode Whether or not to create a separate node to add nodes to.

add_external_nodes_to_secondary_provider()   X-Ref
Provider for the add_external_nodes_to_secondary function.

return: array

test_get_overflow_menu_data(string $selectedurl, bool $expectednull, bool $emptynode = false)   X-Ref
Test the get_overflow_menu_data function

param: string $selectedurl
param: bool $expectednull
param: bool $emptynode

get_overflow_menu_data_provider()   X-Ref
Data provider for test_get_overflow_menu_data

return: string[]

test_get_overflow_menu_data_course_admin(string $url, string $contextidentifier, bool $expected)   X-Ref
Test the course administration settings return an overflow menu.

param: string $url Url of the page we are testing.
param: string $contextidentifier id or contextid or something similar.
param: bool $expected The expected return. True to return the overflow menu otherwise false for nothing.

get_overflow_menu_data_course_admin_provider()   X-Ref
Data provider for the other half of the method thing

return: array Provider information.