New init function for plugins, supports errors reporting

All plugins can optionally add an init function named `pluginname_init()` which is called when the plugin is loaded.

This function is aware of the config, and can return initialization errors, which are displayed in the header template.

Note that the previous error system hack no longer work.
This commit is contained in:
ArthurHoaro 2016-10-14 13:22:58 +02:00
parent f63632a6fb
commit 7fde6de121
8 changed files with 115 additions and 15 deletions

View file

@ -4,8 +4,6 @@
* PluginReadityourselfTest.php.php
*/
// FIXME! add an init method.
$conf = new ConfigManager('');
require_once 'plugins/readityourself/readityourself.php';
/**
@ -22,6 +20,27 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
PluginManager::$PLUGINS_PATH = 'plugins';
}
/**
* Test Readityourself init without errors.
*/
function testReadityourselfInitNoError()
{
$conf = new ConfigManager('');
$conf->set('plugins.READITYOUSELF_URL', 'value');
$errors = readityourself_init($conf);
$this->assertEmpty($errors);
}
/**
* Test Readityourself init with errors.
*/
function testReadityourselfInitError()
{
$conf = new ConfigManager('');
$errors = readityourself_init($conf);
$this->assertNotEmpty($errors);
}
/**
* Test render_linklist hook.
*/

View file

@ -4,8 +4,6 @@
* PluginWallabagTest.php.php
*/
// FIXME! add an init method.
$conf = new ConfigManager('');
require_once 'plugins/wallabag/wallabag.php';
/**
@ -22,6 +20,27 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
PluginManager::$PLUGINS_PATH = 'plugins';
}
/**
* Test wallabag init without errors.
*/
function testWallabagInitNoError()
{
$conf = new ConfigManager('');
$conf->set('plugins.WALLABAG_URL', 'value');
$errors = wallabag_init($conf);
$this->assertEmpty($errors);
}
/**
* Test wallabag init with errors.
*/
function testWallabagInitError()
{
$conf = new ConfigManager('');
$errors = wallabag_init($conf);
$this->assertNotEmpty($errors);
}
/**
* Test render_linklist hook.
*/