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 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

(no description)

File Size: 436 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: primary_test  - X-Ref

Primary navigation renderable test

setUp()   X-Ref
Basic setup to make sure the nav objects gets generated without any issues.


test_primary_export(bool $withcustom, bool $withlang, string $userloggedin, array $expecteditems)   X-Ref
Test the primary export to confirm we are getting the nodes

param: bool $withcustom Setup with custom menu
param: bool $withlang Setup with langs
param: string $userloggedin The type of user ('admin' or 'guest') if creating setup with logged in user,
param: array $expecteditems An array of nodes expected with content in them.

primary_export_provider()   X-Ref
Provider for the test_primary_export function.

return: array

test_get_custom_menu(string $config, array $expected)   X-Ref
Test the custom menu getter to confirm the nodes gets generated and are returned correctly.

param: string $config
param: array $expected

get_custom_menu(string $config)   X-Ref
Helper method to get the template data for the custommenuitem that is set here via parameter.

param: string $config
return: array

custom_menu_provider()   X-Ref
Provider for test_get_custom_menu

return: array

test_merge_primary_and_custom()   X-Ref
Test the merge_primary_and_custom and the eval_is_active method. Merge  primary and custom menu with different
page urls and check that the correct nodes are active and open, depending on the data for each menu.

return: void

merge_and_render_menus(?string $url = null, ?bool $ismobile = false)   X-Ref
Internal function to get an array of top menu items from the primary and the custom menu. The latter is defined
in this function.

param: string|null $url
param: bool|null $ismobile
return: array

get_menu_item_names_by_type(array $menu, string $nodetype)   X-Ref
Traverse the menu array structure (all nodes recursively) and fetch the node texts from the menu nodes that are
active/open (determined via param $nodetype that can be "inactive" or "isopen"). The returned array contains a
list of nade names that match this criterion.

param: array $menu
param: string $nodetype
return: array