mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'MDL-83253-404' of https://github.com/andrewnicols/moodle into MOODLE_404_STABLE
This commit is contained in:
commit
b2cf67e4f5
@ -2641,7 +2641,13 @@ function get_deprecated_capability_info($capabilityname) {
|
||||
foreach ($allcaps as $cap) {
|
||||
if (!in_array($cap['component'], $components)) {
|
||||
$components[] = $cap['component'];
|
||||
$defpath = core_component::get_component_directory($cap['component']).'/db/access.php';
|
||||
|
||||
$componentdir = core_component::get_component_directory($cap['component']);
|
||||
if ($componentdir === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$defpath = "{$componentdir}/db/access.php";
|
||||
if (file_exists($defpath)) {
|
||||
$deprecatedcapabilities = [];
|
||||
require($defpath);
|
||||
|
@ -2114,6 +2114,38 @@ class accesslib_test extends advanced_testcase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get_deprecated_capability_info() with an invalid component.
|
||||
*
|
||||
* @covers get_deprecated_capability_info
|
||||
*/
|
||||
public function test_get_deprecated_capability_info_invalid_component(): void {
|
||||
global $DB;
|
||||
|
||||
$this->resetAfterTest();
|
||||
|
||||
// Set up a fake plugin.
|
||||
$this->setup_fake_plugin('access');
|
||||
|
||||
// Add a plugin for an unrelated fake component.
|
||||
$DB->insert_record('capabilities', [
|
||||
'name' => 'mod/fake:addinstance',
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'component' => 'mod_fake',
|
||||
'riskbitmask' => 4,
|
||||
]);
|
||||
|
||||
// Purge the cache.
|
||||
cache::make('core', 'capabilities')->purge();
|
||||
|
||||
// For now we have deprecated fake/access:fakecapability.
|
||||
$this->assertNotEmpty($DB->get_record('capabilities', ['component' => 'mod_fake']));
|
||||
$info = get_deprecated_capability_info('fake/access:fakecapability');
|
||||
$this->assertIsArray($info);
|
||||
$this->assertDebuggingNotCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that assigning a fake cap does not return.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user