mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-81648 course: Add a method to retrieve delegate section parent
- New 'get_parent_section()' function added to sectiondelegate abstract class
This commit is contained in:
parent
bcd8e0d6ed
commit
b4ecd9d805
@ -124,4 +124,13 @@ abstract class sectiondelegate {
|
||||
): ?action_menu {
|
||||
return $controlmenu->get_default_action_menu($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent section of the current delegated section if any.
|
||||
*
|
||||
* @return section_info|null
|
||||
*/
|
||||
public function get_parent_section(): ?section_info {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -141,4 +141,21 @@ class sectiondelegate_test extends \advanced_testcase {
|
||||
$result = $delegated->get_section_action_menu($format, $controlmenu, $renderer);
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_parent_section().
|
||||
*
|
||||
* @covers ::get_parent_section
|
||||
*/
|
||||
public function test_get_parent_section(): void {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 1]);
|
||||
$sectioninfo = formatactions::section($course)->create_delegated('test_component', 1);
|
||||
|
||||
/** @var testsectiondelegate */
|
||||
$delegated = $sectioninfo->get_component_instance();
|
||||
|
||||
$this->assertNull($delegated->get_parent_section());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user