aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PluginManagerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r--tests/PluginManagerTest.php66
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
7require_once 'application/PluginManager.php';
8
9/**
10 * Unit tests for Plugins
11 */
12class 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