X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=a5d5dbe988ea22ad525ed74a71b5c3d421c2d7ec;hb=9e2d47e519783a991962e1fe2c9f28d77756ae49;hp=01de959c5266bb9e877f7e425e5a5af9e2cc673d;hpb=3c66e56435359dc678048193e8ee239d06f79b64;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 01de959c..a5d5dbe9 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -1,16 +1,12 @@ pluginManager = new PluginManager($conf); @@ -37,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)); @@ -60,21 +54,39 @@ 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));