Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

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: 0 times
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: testable_plugininfo_base $record
return: void