MDL-82510 course: Add new delegated action menu

This commit is contained in:
Amaia Anabitarte
2024-07-19 08:27:10 +02:00
parent 554a790bf0
commit ff6edc2e9f
9 changed files with 513 additions and 113 deletions
@@ -64,12 +64,24 @@ final class sectiondelegate_test extends \advanced_testcase {
$controlmenu = new $outputclass($format, $sectioninfo);
$renderer = $PAGE->get_renderer('format_' . $course->format);
// Highlight is only present in section menu (not module), so they shouldn't be found in the result.
// Duplicate is not implemented yet, so they shouldn't be found in the result.
// The possible options are: View, Edit, Delete and Permalink.
if (get_string_manager()->string_exists('editsection', 'format_'.$format->get_format())) {
$streditsection = get_string('editsection', 'format_'.$format->get_format());
} else {
$streditsection = get_string('editsection');
}
$allowedoptions = [
get_string('view'),
$streditsection,
get_string('delete'),
get_string('sectionlink', 'course'),
];
// The default section menu should be different for the delegated section menu.
$result = $delegated->get_section_action_menu($format, $controlmenu, $renderer);
foreach ($result->get_secondary_actions() as $secondaryaction) {
// Highlight and Permalink are only present in section menu (not module), so they shouldn't be find in the result.
$this->assertNotEquals(get_string('highlight'), $secondaryaction->text);
$this->assertNotEquals(get_string('sectionlink', 'course'), $secondaryaction->text);
$this->assertContains($secondaryaction->text, $allowedoptions);
}
}
}