X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=71761ac17db62f18eb199f4f85e32774b4ae2cf4;hb=dea72c711ff740b3b829d238fcf85648465143a0;hp=df2614b557d8cf94a03679531e3a4e125706a440;hpb=fd006c630b64146edc402b68d8503c716f8a55d6;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index df2614b5..71761ac1 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -1,15 +1,12 @@ pluginManager = new PluginManager($conf); + } + /** * Test plugin loading and hook execution. * @@ -30,23 +38,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 +63,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 +}