aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PluginManagerTest.php
diff options
context:
space:
mode:
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}