From 51def0d84955c7a951bd091eb5eeb3fce9deabd4 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 9 Jun 2016 20:04:32 +0200 Subject: PluginManager no longer uses singleton pattern --- tests/PluginManagerTest.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'tests/PluginManagerTest.php') diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 348082c7..61efce68 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -23,6 +23,17 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase */ private static $pluginName = 'test'; + /** + * @var PluginManager $pluginManager Plugin Mananger instance. + */ + protected $pluginManager; + + public function setUp() + { + $conf = new ConfigManager(''); + $this->pluginManager = new PluginManager($conf); + } + /** * Test plugin loading and hook execution. * @@ -30,23 +41,21 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase */ public function testPlugin() { - $pluginManager = PluginManager::getInstance(); - PluginManager::$PLUGINS_PATH = self::$pluginPath; - $pluginManager->load(array(self::$pluginName)); + $this->pluginManager->load(array(self::$pluginName)); $this->assertTrue(function_exists('hook_test_random')); $data = array(0 => 'woot'); - $pluginManager->executeHooks('random', $data); + $this->pluginManager->executeHooks('random', $data); $this->assertEquals('woot', $data[1]); $data = array(0 => 'woot'); - $pluginManager->executeHooks('random', $data, array('target' => 'test')); + $this->pluginManager->executeHooks('random', $data, array('target' => 'test')); $this->assertEquals('page test', $data[1]); $data = array(0 => 'woot'); - $pluginManager->executeHooks('random', $data, array('loggedin' => true)); + $this->pluginManager->executeHooks('random', $data, array('loggedin' => true)); $this->assertEquals('loggedin', $data[1]); } @@ -57,11 +66,8 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase */ public function testPluginNotFound() { - $pluginManager = PluginManager::getInstance(); - - $pluginManager->load(array()); - - $pluginManager->load(array('nope', 'renope')); + $this->pluginManager->load(array()); + $this->pluginManager->load(array('nope', 'renope')); } /** @@ -69,16 +75,14 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase */ public function testGetPluginsMeta() { - $pluginManager = PluginManager::getInstance(); - PluginManager::$PLUGINS_PATH = self::$pluginPath; - $pluginManager->load(array(self::$pluginName)); + $this->pluginManager->load(array(self::$pluginName)); $expectedParameters = array( 'pop' => '', 'hip' => '', ); - $meta = $pluginManager->getPluginsMeta(); + $meta = $this->pluginManager->getPluginsMeta(); $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); } -- cgit v1.2.3 From 15170b516429341ae8e1a9ad2111be5ef90bf6aa Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 2 Aug 2016 11:02:20 +0200 Subject: Parse plugin parameters description with the PluginManager Plugin parameter can contain a description in their meta file under the key: parameter.="" --- tests/PluginManagerTest.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/PluginManagerTest.php') diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 61efce68..f4826e2e 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -79,8 +79,14 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase $this->pluginManager->load(array(self::$pluginName)); $expectedParameters = array( - 'pop' => '', - 'hip' => '', + 'pop' => array( + 'value' => '', + 'desc' => 'pop description', + ), + 'hip' => array( + 'value' => '', + 'desc' => '', + ), ); $meta = $this->pluginManager->getPluginsMeta(); $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); -- cgit v1.2.3 From db6dec0de10d0ee3b35658ae9f431935d17e8a7c Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 13 Aug 2016 14:22:22 +0200 Subject: Fix: add missing final newlines, untabify text Signed-off-by: VirtualTam --- tests/PluginManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/PluginManagerTest.php') diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 61efce68..c7511051 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -86,4 +86,4 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); } -} \ No newline at end of file +} -- cgit v1.2.3