Skip to content

Commit

Permalink
Merge branch 'MDL-75077-400' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
…into MOODLE_400_STABLE
  • Loading branch information
sarjona committed Oct 17, 2022
2 parents b169ba0 + 3afbd2a commit 27c2863
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/outputcomponents.php
Expand Up @@ -3657,6 +3657,7 @@ public function export_for_template(renderer_base $output) {
$syscontext = context_system::instance();

$context = new stdClass();
$context->moremenuid = uniqid();
$context->text = external_format_string($this->text, $syscontext->id);
$context->url = $this->url ? $this->url->out() : null;
// No need for the title if it's the same with text.
Expand Down
15 changes: 14 additions & 1 deletion lib/tests/navigation/output/primary_test.php
Expand Up @@ -159,7 +159,20 @@ public function test_get_custom_menu(string $config, array $expected) {
$method = new ReflectionMethod('core\navigation\output\primary', 'get_custom_menu');
$method->setAccessible(true);
$renderer = $PAGE->get_renderer('core');
$this->assertEquals($expected, $method->invoke($output, $renderer));

// We can't assert the value of each menuitem "moremenuid" property (because it's random).
$custommenufilter = static function(array $custommenu) use (&$custommenufilter): void {
foreach ($custommenu as $menuitem) {
unset($menuitem->moremenuid);
// Recursively move through child items.
$custommenufilter($menuitem->children);
}
};

$actual = $method->invoke($output, $renderer);
$custommenufilter($actual);

$this->assertEquals($expected, $actual);
}

/**
Expand Down

0 comments on commit 27c2863

Please sign in to comment.