MDL-82541 core_courseformat: delegated sections in disabled plugins

This commit is contained in:
ferranrecio
2024-09-12 16:07:42 +02:00
parent 3477082aa9
commit ebaf06848c
8 changed files with 257 additions and 15 deletions
@@ -76,6 +76,33 @@ class sectiondelegate_test extends \advanced_testcase {
$this->assertNull(sectiondelegate::instance($sectioninfos[3]));
}
/**
* Test that the instance method returns null when the delegate class is disabled.
*
* @covers ::instance
*/
public function test_instance_disabled(): void {
global $DB;
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 3]);
// Section 2 has an existing delegate class.
course_update_section(
$course,
$DB->get_record('course_sections', ['course' => $course->id, 'section' => 2]),
[
'component' => 'test_component',
'itemid' => testsectiondelegate::DISABLEDITEMID,
]
);
$modinfo = get_fast_modinfo($course->id);
$sectioninfos = $modinfo->get_section_info_all();
$this->assertNull(sectiondelegate::instance($sectioninfos[2]));
}
/**
* Test has_delegate_class().
*