X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=01de959c5266bb9e877f7e425e5a5af9e2cc673d;hb=fab87c2696b9d6a26310f1bfc024b018ca5184fe;hp=df2614b557d8cf94a03679531e3a4e125706a440;hpb=d06265fb5785493ee845d4c4a86583402b475b60;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index df2614b5..01de959c 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -1,4 +1,5 @@ pluginManager = new PluginManager($conf); + } + /** * Test plugin loading and hook execution. * @@ -30,23 +42,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,10 +67,30 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase */ public function testPluginNotFound() { - $pluginManager = PluginManager::getInstance(); + $this->pluginManager->load(array()); + $this->pluginManager->load(array('nope', 'renope')); + } - $pluginManager->load(array()); + /** + * Test plugin metadata loading. + */ + public function testGetPluginsMeta() + { + PluginManager::$PLUGINS_PATH = self::$pluginPath; + $this->pluginManager->load(array(self::$pluginName)); - $pluginManager->load(array('nope', 'renope')); + $expectedParameters = array( + 'pop' => array( + 'value' => '', + 'desc' => 'pop description', + ), + 'hip' => array( + 'value' => '', + 'desc' => '', + ), + ); + $meta = $this->pluginManager->getPluginsMeta(); + $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); + $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); } -} \ No newline at end of file +}