X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=a5d5dbe988ea22ad525ed74a71b5c3d421c2d7ec;hb=2835ac7cbe65fd2b602cadad5e9d6b09eb670d59;hp=c751105132f80ea1cd233525fdc1e6c18fd7b260;hpb=db6dec0de10d0ee3b35658ae9f431935d17e8a7c;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index c7511051..a5d5dbe9 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -1,15 +1,12 @@ pluginManager = new PluginManager($conf); @@ -36,10 +33,8 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase /** * Test plugin loading and hook execution. - * - * @return void */ - public function testPlugin() + public function testPlugin(): void { PluginManager::$PLUGINS_PATH = self::$pluginPath; $this->pluginManager->load(array(self::$pluginName)); @@ -59,28 +54,52 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase $this->assertEquals('loggedin', $data[1]); } + /** + * Test plugin loading and hook execution with an error: raise an incompatibility error. + */ + public function testPluginWithPhpError(): void + { + PluginManager::$PLUGINS_PATH = self::$pluginPath; + $this->pluginManager->load(array(self::$pluginName)); + + $this->assertTrue(function_exists('hook_test_error')); + + $data = []; + $this->pluginManager->executeHooks('error', $data); + + $this->assertSame( + 'test [plugin incompatibility]: Class \'Unknown\' not found', + $this->pluginManager->getErrors()[0] + ); + } + /** * Test missing plugin loading. - * - * @return void */ - public function testPluginNotFound() + public function testPluginNotFound(): void { $this->pluginManager->load(array()); $this->pluginManager->load(array('nope', 'renope')); + $this->addToAssertionCount(1); } /** * Test plugin metadata loading. */ - public function testGetPluginsMeta() + public function testGetPluginsMeta(): void { PluginManager::$PLUGINS_PATH = self::$pluginPath; $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']);