aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PluginManagerTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-12-16 16:04:15 +0100
committerGitHub <noreply@github.com>2020-12-16 16:04:15 +0100
commitbd11879018416d2c5d87728bb0be6ee0cf54451a (patch)
treef3147ab9eef24ff430c131249166fe84d19a4b07 /tests/PluginManagerTest.php
parent8f423eb11c6642d96b5144f56e4698652591ad6b (diff)
parenta6e9c08499f9f79dad88cb3ae9eacda0e0c34c96 (diff)
downloadShaarli-bd11879018416d2c5d87728bb0be6ee0cf54451a.tar.gz
Shaarli-bd11879018416d2c5d87728bb0be6ee0cf54451a.tar.zst
Shaarli-bd11879018416d2c5d87728bb0be6ee0cf54451a.zip
Merge pull request #1645 from ArthurHoaro/feature/plugin-register-route
Plugin system: allow plugins to provide custom routes
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}