MDL-61875 core_component: new method to get full components list
This commit is contained in:
@@ -779,4 +779,30 @@ class core_component_testcase extends advanced_testcase {
|
||||
$file = $psrclassloader->invokeArgs(null, array($classname, $prefix, $path, $separators));
|
||||
$this->assertEquals($result, $file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the get_component_list method contains an entry for every component.
|
||||
*/
|
||||
public function test_get_component_list_contains_all_components() {
|
||||
global $CFG;
|
||||
$componentslist = \core_component::get_component_list();
|
||||
|
||||
// We should have an entry for each plugin type, and one additional for 'core'.
|
||||
$plugintypes = \core_component::get_plugin_types();
|
||||
$numelementsexpected = count($plugintypes) + 1;
|
||||
$this->assertEquals($numelementsexpected, count($componentslist));
|
||||
|
||||
// And an entry for each of the plugin types.
|
||||
foreach (array_keys($plugintypes) as $plugintype) {
|
||||
$this->assertArrayHasKey($plugintype, $componentslist);
|
||||
}
|
||||
|
||||
// And finally, one for 'core'.
|
||||
$this->assertArrayHasKey('core', $componentslist);
|
||||
|
||||
// Check a few of the known plugin types to confirm their presence at their respective type index.
|
||||
$this->assertEquals($componentslist['core']['core_comment'], $CFG->dirroot . '/comment');
|
||||
$this->assertEquals($componentslist['mod']['mod_forum'], $CFG->dirroot . '/mod/forum');
|
||||
$this->assertEquals($componentslist['tool']['tool_analytics'], $CFG->dirroot . '/admin/tool/analytics');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user