aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PluginManagerTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-06-09 20:04:32 +0200
committerArthurHoaro <arthur@hoa.ro>2016-06-11 09:30:56 +0200
commit51def0d84955c7a951bd091eb5eeb3fce9deabd4 (patch)
tree466c24f215ee4d25bdcce67100b11e2fd3b0c78b /tests/PluginManagerTest.php
parent278d9ee2836df7d805845077f26f8cecd16f0f4f (diff)
downloadShaarli-51def0d84955c7a951bd091eb5eeb3fce9deabd4.tar.gz
Shaarli-51def0d84955c7a951bd091eb5eeb3fce9deabd4.tar.zst
Shaarli-51def0d84955c7a951bd091eb5eeb3fce9deabd4.zip
PluginManager no longer uses singleton pattern
Diffstat (limited to 'tests/PluginManagerTest.php')
-rw-r--r--tests/PluginManagerTest.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php
index 348082c7..61efce68 100644
--- a/tests/PluginManagerTest.php
+++ b/tests/PluginManagerTest.php
@@ -24,29 +24,38 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase
24 private static $pluginName = 'test'; 24 private static $pluginName = 'test';
25 25
26 /** 26 /**
27 * @var PluginManager $pluginManager Plugin Mananger instance.
28 */
29 protected $pluginManager;
30
31 public function setUp()
32 {
33 $conf = new ConfigManager('');
34 $this->pluginManager = new PluginManager($conf);
35 }
36
37 /**
27 * Test plugin loading and hook execution. 38 * Test plugin loading and hook execution.
28 * 39 *
29 * @return void 40 * @return void
30 */ 41 */
31 public function testPlugin() 42 public function testPlugin()
32 { 43 {
33 $pluginManager = PluginManager::getInstance();
34
35 PluginManager::$PLUGINS_PATH = self::$pluginPath; 44 PluginManager::$PLUGINS_PATH = self::$pluginPath;
36 $pluginManager->load(array(self::$pluginName)); 45 $this->pluginManager->load(array(self::$pluginName));
37 46
38 $this->assertTrue(function_exists('hook_test_random')); 47 $this->assertTrue(function_exists('hook_test_random'));
39 48
40 $data = array(0 => 'woot'); 49 $data = array(0 => 'woot');
41 $pluginManager->executeHooks('random', $data); 50 $this->pluginManager->executeHooks('random', $data);
42 $this->assertEquals('woot', $data[1]); 51 $this->assertEquals('woot', $data[1]);
43 52
44 $data = array(0 => 'woot'); 53 $data = array(0 => 'woot');
45 $pluginManager->executeHooks('random', $data, array('target' => 'test')); 54 $this->pluginManager->executeHooks('random', $data, array('target' => 'test'));
46 $this->assertEquals('page test', $data[1]); 55 $this->assertEquals('page test', $data[1]);
47 56
48 $data = array(0 => 'woot'); 57 $data = array(0 => 'woot');
49 $pluginManager->executeHooks('random', $data, array('loggedin' => true)); 58 $this->pluginManager->executeHooks('random', $data, array('loggedin' => true));
50 $this->assertEquals('loggedin', $data[1]); 59 $this->assertEquals('loggedin', $data[1]);
51 } 60 }
52 61
@@ -57,11 +66,8 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase
57 */ 66 */
58 public function testPluginNotFound() 67 public function testPluginNotFound()
59 { 68 {
60 $pluginManager = PluginManager::getInstance(); 69 $this->pluginManager->load(array());
61 70 $this->pluginManager->load(array('nope', 'renope'));
62 $pluginManager->load(array());
63
64 $pluginManager->load(array('nope', 'renope'));
65 } 71 }
66 72
67 /** 73 /**
@@ -69,16 +75,14 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase
69 */ 75 */
70 public function testGetPluginsMeta() 76 public function testGetPluginsMeta()
71 { 77 {
72 $pluginManager = PluginManager::getInstance();
73
74 PluginManager::$PLUGINS_PATH = self::$pluginPath; 78 PluginManager::$PLUGINS_PATH = self::$pluginPath;
75 $pluginManager->load(array(self::$pluginName)); 79 $this->pluginManager->load(array(self::$pluginName));
76 80
77 $expectedParameters = array( 81 $expectedParameters = array(
78 'pop' => '', 82 'pop' => '',
79 'hip' => '', 83 'hip' => '',
80 ); 84 );
81 $meta = $pluginManager->getPluginsMeta(); 85 $meta = $this->pluginManager->getPluginsMeta();
82 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); 86 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']);
83 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); 87 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']);
84 } 88 }