X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=ddf4818533a1777f422421feb29b44e7243a7afa;hb=5ebc1d504bc8a8f29f49a8a4fc1c421f78677b2a;hp=348082c763c2dde8a25c474ae0979248a6a9ad0e;hpb=268a2e52659964fb7d033a1bb4d1490bf8cc49bf;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 348082c7..ddf48185 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,17 +75,21 @@ 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' => '', + 'pop' => array( + 'value' => '', + 'desc' => 'pop description', + ), + 'hip' => array( + 'value' => '', + 'desc' => '', + ), ); - $meta = $pluginManager->getPluginsMeta(); + $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 +}