Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

Provides testable_core_plugin_manager class.

Copyright: 2015 David Mudrak <david@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 124 lines (4 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 1 file
 lib/tests/fixtures/testable_update_api.php

Defines 1 class

testable_core_plugin_manager:: (4 methods):
  inject_testable_plugininfo()
  get_update_api_client()
  load_available_updates_for_plugin()
  add_fake_plugin_info()


Class: testable_core_plugin_manager  - X-Ref

Testable variant of the core_plugin_manager

inject_testable_plugininfo($type, $name, \core\plugininfo\base $plugininfo)   X-Ref
Allows us to inject items directly into the plugins info tree.

Do not forget to call our reset_caches() after using this method to force a new
singleton instance.

param: string $type plugin type
param: string $name plugin name
param: \core\plugininfo\base $plugininfo plugin info class

get_update_api_client()   X-Ref
Returns testable subclass of the client.

return: \core\update\testable_api

load_available_updates_for_plugin($component)   X-Ref
Mockup implementation of loading available updates info.

This testable implementation does not actually use
{@link \core\update\checker}. Instead, it provides hard-coded list of
fictional available updates for our foo_bar plugin.

Note there is a difference in the behaviour as the actual update API
does not return info of lower version than requested. To mock up well,
make sure the injected foo_bar testable plugin info has version lower
than the lowest one returned here.

param: string $component
return: array|null array of \core\update\info objects or null

add_fake_plugin_info($record)   X-Ref
Adds fake plugin information from record.

param: stdClass $record
return: void