diff options
author | Arthur <arthur@hoa.ro> | 2015-11-08 13:29:32 +0100 |
---|---|---|
committer | Arthur <arthur@hoa.ro> | 2015-11-08 13:29:32 +0100 |
commit | fd006c630b64146edc402b68d8503c716f8a55d6 (patch) | |
tree | e53904cc6232c7f2fe8e1de6f23c9a5d6c5403ad /tests/PluginManagerTest.php | |
parent | 70df947af60afb05529024bb2d3825eaf6cc7950 (diff) | |
parent | 056107ab4eae0a4867cf8d55de77d31f8868b899 (diff) | |
download | Shaarli-fd006c630b64146edc402b68d8503c716f8a55d6.tar.gz Shaarli-fd006c630b64146edc402b68d8503c716f8a55d6.tar.zst Shaarli-fd006c630b64146edc402b68d8503c716f8a55d6.zip |
Merge pull request #275 from shaarli/plugin-proposition
Plugin proposition
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r-- | tests/PluginManagerTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php new file mode 100644 index 00000000..df2614b5 --- /dev/null +++ b/tests/PluginManagerTest.php | |||
@@ -0,0 +1,66 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Plugin Manager tests | ||
5 | */ | ||
6 | |||
7 | require_once 'application/PluginManager.php'; | ||
8 | |||
9 | /** | ||
10 | * Unit tests for Plugins | ||
11 | */ | ||
12 | class PluginManagerTest extends PHPUnit_Framework_TestCase | ||
13 | { | ||
14 | /** | ||
15 | * Path to tests plugin. | ||
16 | * @var string $pluginPath | ||
17 | */ | ||
18 | private static $pluginPath = 'tests/plugins'; | ||
19 | |||
20 | /** | ||
21 | * Test plugin. | ||
22 | * @var string $pluginName | ||
23 | */ | ||
24 | private static $pluginName = 'test'; | ||
25 | |||
26 | /** | ||
27 | * Test plugin loading and hook execution. | ||
28 | * | ||
29 | * @return void | ||
30 | */ | ||
31 | public function testPlugin() | ||
32 | { | ||
33 | $pluginManager = PluginManager::getInstance(); | ||
34 | |||
35 | PluginManager::$PLUGINS_PATH = self::$pluginPath; | ||
36 | $pluginManager->load(array(self::$pluginName)); | ||
37 | |||
38 | $this->assertTrue(function_exists('hook_test_random')); | ||
39 | |||
40 | $data = array(0 => 'woot'); | ||
41 | $pluginManager->executeHooks('random', $data); | ||
42 | $this->assertEquals('woot', $data[1]); | ||
43 | |||
44 | $data = array(0 => 'woot'); | ||
45 | $pluginManager->executeHooks('random', $data, array('target' => 'test')); | ||
46 | $this->assertEquals('page test', $data[1]); | ||
47 | |||
48 | $data = array(0 => 'woot'); | ||
49 | $pluginManager->executeHooks('random', $data, array('loggedin' => true)); | ||
50 | $this->assertEquals('loggedin', $data[1]); | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * Test missing plugin loading. | ||
55 | * | ||
56 | * @return void | ||
57 | */ | ||
58 | public function testPluginNotFound() | ||
59 | { | ||
60 | $pluginManager = PluginManager::getInstance(); | ||
61 | |||
62 | $pluginManager->load(array()); | ||
63 | |||
64 | $pluginManager->load(array('nope', 'renope')); | ||
65 | } | ||
66 | } \ No newline at end of file | ||