aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PluginManagerTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-27 19:23:45 +0100
committerArthurHoaro <arthur@hoa.ro>2020-11-15 12:41:43 +0100
commita6e9c08499f9f79dad88cb3ae9eacda0e0c34c96 (patch)
tree41f70d7dc478e70a4a3ce4a578839316f5578765 /tests/PluginManagerTest.php
parent6f9e0609f4c118142504234ebcc7d93456b5e588 (diff)
downloadShaarli-a6e9c08499f9f79dad88cb3ae9eacda0e0c34c96.tar.gz
Shaarli-a6e9c08499f9f79dad88cb3ae9eacda0e0c34c96.tar.zst
Shaarli-a6e9c08499f9f79dad88cb3ae9eacda0e0c34c96.zip
Plugin system: allow plugins to provide custom routes
- each route will be prefixed by `/plugin/<plugin_name>` - add a new template for plugins rendering - add a live example in the demo_plugin Check out the "Plugin System" documentation for more detail. Related to #143
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r--tests/PluginManagerTest.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php
index efef5e87..8947f679 100644
--- a/tests/PluginManagerTest.php
+++ b/tests/PluginManagerTest.php
@@ -120,4 +120,43 @@ class PluginManagerTest extends \Shaarli\TestCase
120 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); 120 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']);
121 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); 121 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']);
122 } 122 }
123
124 /**
125 * Test plugin custom routes - note that there is no check on callable functions
126 */
127 public function testRegisteredRoutes(): void
128 {
129 PluginManager::$PLUGINS_PATH = self::$pluginPath;
130 $this->pluginManager->load([self::$pluginName]);
131
132 $expectedParameters = [
133 [
134 'method' => 'GET',
135 'route' => '/test',
136 'callable' => 'getFunction',
137 ],
138 [
139 'method' => 'POST',
140 'route' => '/custom',
141 'callable' => 'postFunction',
142 ],
143 ];
144 $meta = $this->pluginManager->getRegisteredRoutes();
145 static::assertSame($expectedParameters, $meta[self::$pluginName]);
146 }
147
148 /**
149 * Test plugin custom routes with invalid route
150 */
151 public function testRegisteredRoutesInvalid(): void
152 {
153 $plugin = 'test_route_invalid';
154 $this->pluginManager->load([$plugin]);
155
156 $meta = $this->pluginManager->getRegisteredRoutes();
157 static::assertSame([], $meta);
158
159 $errors = $this->pluginManager->getErrors();
160 static::assertSame(['test_route_invalid [plugin incompatibility]: trying to register invalid route.'], $errors);
161 }
123} 162}