Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 119... Línea 119...
119
    public function add_fake_plugin_info($record): void {
119
    public function add_fake_plugin_info($record): void {
120
        $this->load_present_plugins();
120
        $this->load_present_plugins();
Línea 121... Línea 121...
121
 
121
 
122
        $this->presentplugins[$record->type][$record->name] = $record;
122
        $this->presentplugins[$record->type][$record->name] = $record;
-
 
123
    }
-
 
124
 
-
 
125
    /**
-
 
126
     * Test-specific override allowing mock plugin types to provide their plugininfo at PATH/TYPE_plugininfo.php instead of the
-
 
127
     * usual core location lib/classes/plugininfo.
-
 
128
     *
-
 
129
     * This is required to:
-
 
130
     * a) prevent debugging calls during tests using deep mocked plugintypes, as their plugininfo can't be located without this
-
 
131
     * override.
-
 
132
     * b) ensure plugin_manager returns an instance of the fixture plugininfo class, during tests using deep mocked plugintypes.
-
 
133
     * If no fixture plugininfo is found, plugin_manager will default to \core\pluginfo\general.
-
 
134
     *
-
 
135
     * @param string $type the plugintype.
-
 
136
     * @return string the name of the plugininfo class.
-
 
137
     */
-
 
138
    public static function resolve_plugininfo_class($type): string {
-
 
139
        $allplugintypes = array_merge(
-
 
140
            \core_component::get_plugin_types(),
-
 
141
            \core_component::get_deprecated_plugin_types(),
-
 
142
            \core_component::get_deleted_plugin_types()
-
 
143
        );
-
 
144
 
-
 
145
        // This is not a problem for mock plugins supporting subtypes, since subtype plugininfo class can be loaded, as expected,
-
 
146
        // from the subtype root directory.
-
 
147
        $issubtype = !is_null(\core_component::get_subtype_parent($type));
-
 
148
 
-
 
149
        $path = $allplugintypes[$type];
-
 
150
        if (!$issubtype && preg_match('/lib\/tests\/fixtures/', $path)) {
-
 
151
            require_once("$path/{$type}_plugininfo.php");
-
 
152
            return "{$type}_plugininfo";
-
 
153
        }
-
 
154
 
-
 
155
        return parent::resolve_plugininfo_class($type);
123
    }
156
    }