diff options
author | yude <yudesleepy@gmail.com> | 2021-01-04 18:51:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 18:51:10 +0900 |
commit | e6754f2154a79abd8e5e64bd923f6984aa9ad44b (patch) | |
tree | f074119530bb59ef155938ea367f719f1e4b70f1 /tests/PluginManagerTest.php | |
parent | 5256b4287021342a9f8868967b2a77e481314331 (diff) | |
parent | ed4ee8f0297941ac83300389b7de6a293312d20e (diff) | |
download | Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.tar.gz Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.tar.zst Shaarli-e6754f2154a79abd8e5e64bd923f6984aa9ad44b.zip |
Merge pull request #2 from shaarli/master
Merge fork source
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r-- | tests/PluginManagerTest.php | 39 |
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 | } |