X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=a5d5dbe988ea22ad525ed74a71b5c3d421c2d7ec;hb=48b19a7014ce7fac58ac77e171526cbb3a751318;hp=ddf4818533a1777f422421feb29b44e7243a7afa;hpb=8758bb0ac8cb68d32122009dbcb977d2f0fad2b0;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index ddf48185..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,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));