X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FPluginManagerTest.php;h=a5d5dbe988ea22ad525ed74a71b5c3d421c2d7ec;hb=7e3dc0ba98bf019c2804e5c74fb6061b16fb712f;hp=195d959c2fc4c3ab3e30d4a07b9b1ce57105a1f1;hpb=af41d5ab5d2bd3ba64d052c997bc6afa6966a63c;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php index 195d959c..a5d5dbe9 100644 --- a/tests/PluginManagerTest.php +++ b/tests/PluginManagerTest.php @@ -25,7 +25,7 @@ class PluginManagerTest extends \PHPUnit\Framework\TestCase */ protected $pluginManager; - public function setUp() + public function setUp(): void { $conf = new ConfigManager(''); $this->pluginManager = new PluginManager($conf); @@ -33,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)); @@ -56,10 +54,29 @@ 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. */ - public function testPluginNotFound() + public function testPluginNotFound(): void { $this->pluginManager->load(array()); $this->pluginManager->load(array('nope', 'renope')); @@ -69,7 +86,7 @@ class PluginManagerTest extends \PHPUnit\Framework\TestCase /** * Test plugin metadata loading. */ - public function testGetPluginsMeta() + public function testGetPluginsMeta(): void { PluginManager::$PLUGINS_PATH = self::$pluginPath; $this->pluginManager->load(array(self::$pluginName));