diff options
author | ArthurHoaro <arthur@hoa.ro> | 2021-02-04 11:11:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 11:11:33 +0100 |
commit | 9db1ccdf2ce8381e1f3acb581d3c6a6def095d8c (patch) | |
tree | 97a618b77d327a5f963c91522988e24db5a9e158 /tests/PluginManagerTest.php | |
parent | 8997ae6c8e24286f7d47981eaf905e80d2481c10 (diff) | |
parent | bcba6bd353161fab456b423e93571ab027d5423c (diff) | |
download | Shaarli-master.tar.gz Shaarli-master.tar.zst Shaarli-master.zip |
New plugin hook: ability to add custom filters to Shaarli search engine
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r-- | tests/PluginManagerTest.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 8947f679..75b3ae00 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | namespace Shaarli\Plugin; | 3 | namespace Shaarli\Plugin; |
4 | 4 | ||
5 | use Shaarli\Bookmark\Bookmark; | ||
5 | use Shaarli\Config\ConfigManager; | 6 | use Shaarli\Config\ConfigManager; |
6 | 7 | ||
7 | /** | 8 | /** |
@@ -159,4 +160,19 @@ class PluginManagerTest extends \Shaarli\TestCase | |||
159 | $errors = $this->pluginManager->getErrors(); | 160 | $errors = $this->pluginManager->getErrors(); |
160 | static::assertSame(['test_route_invalid [plugin incompatibility]: trying to register invalid route.'], $errors); | 161 | static::assertSame(['test_route_invalid [plugin incompatibility]: trying to register invalid route.'], $errors); |
161 | } | 162 | } |
163 | |||
164 | public function testSearchFilterPlugin(): void | ||
165 | { | ||
166 | PluginManager::$PLUGINS_PATH = self::$pluginPath; | ||
167 | $this->pluginManager->load([self::$pluginName]); | ||
168 | |||
169 | static::assertNull($this->pluginManager->getFilterSearchEntryHooks()); | ||
170 | |||
171 | static::assertTrue($this->pluginManager->filterSearchEntry(new Bookmark(), ['_result' => true])); | ||
172 | |||
173 | static::assertCount(1, $this->pluginManager->getFilterSearchEntryHooks()); | ||
174 | static::assertSame('hook_test_filter_search_entry', $this->pluginManager->getFilterSearchEntryHooks()[0]); | ||
175 | |||
176 | static::assertFalse($this->pluginManager->filterSearchEntry(new Bookmark(), ['_result' => false])); | ||
177 | } | ||
162 | } | 178 | } |