1441 |
ariadna |
1 |
# Mock plugin: 'fake_fullfeatured'
|
|
|
2 |
A mock plugin, useful for testing various lower level core_component-related APIs, without coupling those tests to existing shipped plugins.
|
|
|
3 |
|
|
|
4 |
This is primarily used to test:
|
|
|
5 |
* core_component::xxx
|
|
|
6 |
* core_plugin_manager::xxx
|
|
|
7 |
* higher level Moodlelib APIs which use the below (e.g. methods dealing with callbacks, strings, etc.)
|
|
|
8 |
|
|
|
9 |
Can be extended with more core features (implementing more APIs, etc.) as needed.
|
|
|
10 |
|
|
|
11 |
Must be injected into core_compoent to be used.
|
|
|
12 |
|
|
|
13 |
## Features
|
|
|
14 |
* Supports the following subplugin types (optional):
|
|
|
15 |
* fullsubtype
|
|
|
16 |
* fulldeprecatedsubtype
|
|
|
17 |
* Provides the following subplugins (optional):
|
|
|
18 |
* fullsubtype_example
|
|
|
19 |
* fulldeprecatedsubtype_test
|
|
|
20 |
|
|
|
21 |
## Usage in phpunit
|
|
|
22 |
**Important:** Using this mock in the following way in tests causes a core_component cache rebuild, can impact other tests, and are slow! Use sparingly and always tag the unit test with ```@runInSeparateProcess```.
|
|
|
23 |
|
|
|
24 |
### Injecting the plugin type into core_component:
|
|
|
25 |
This is done at a low level and will cause core_component to rebuild, which will impact other tests.
|
|
|
26 |
|
|
|
27 |
$this->add_full_mocked_plugintype(
|
|
|
28 |
plugintype: 'fake',
|
|
|
29 |
path: 'lib/tests/fixtures/fakeplugins/fake',
|
|
|
30 |
);
|
|
|
31 |
|
|
|
32 |
If you want to add subplugin support (this will inject the plugin type 'fake' into the plugin types supporting subplugins, which then permits the loading of any plugins under *fullsubtype/* and *fulldeprecatedsubtype/*):
|
|
|
33 |
|
|
|
34 |
$this->add_full_mocked_plugintype(
|
|
|
35 |
plugintype: 'fake',
|
|
|
36 |
path: 'lib/tests/fixtures/fakeplugins/fake',
|
|
|
37 |
subpluginsupport: true
|
|
|
38 |
);
|
|
|
39 |
|
|
|
40 |
|