From eeea1c3daa87f133c57c96fa17ed26b02c392636 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 29 May 2016 14:41:30 +0200 Subject: Use the configuration manager for wallabag and readityourself plugin --- tests/plugins/PluginWallabagTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/plugins/PluginWallabagTest.php') diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php index 5d3a60e0..e6f8a8b6 100644 --- a/tests/plugins/PluginWallabagTest.php +++ b/tests/plugins/PluginWallabagTest.php @@ -25,7 +25,8 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase */ function testWallabagLinklist() { - $GLOBALS['plugins']['WALLABAG_URL'] = 'value'; + $conf = ConfigManager::getInstance(); + $conf->set('plugins.WALLABAG_URL', 'value'); $str = 'http://randomstr.com/test'; $data = array( 'title' => $str, @@ -45,7 +46,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase // plugin data $this->assertEquals(1, count($link['link_plugin'])); $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str))); - $this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL'])); + $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL'))); } } -- cgit v1.2.3 From 51def0d84955c7a951bd091eb5eeb3fce9deabd4 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 9 Jun 2016 20:04:32 +0200 Subject: PluginManager no longer uses singleton pattern --- tests/plugins/PluginWallabagTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests/plugins/PluginWallabagTest.php') diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php index e6f8a8b6..302ee296 100644 --- a/tests/plugins/PluginWallabagTest.php +++ b/tests/plugins/PluginWallabagTest.php @@ -4,6 +4,8 @@ * PluginWallabagTest.php.php */ +// FIXME! add an init method. +$conf = new ConfigManager(''); require_once 'plugins/wallabag/wallabag.php'; /** @@ -25,7 +27,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase */ function testWallabagLinklist() { - $conf = ConfigManager::getInstance(); + $conf = new ConfigManager(''); $conf->set('plugins.WALLABAG_URL', 'value'); $str = 'http://randomstr.com/test'; $data = array( @@ -37,7 +39,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase ) ); - $data = hook_wallabag_render_linklist($data); + $data = hook_wallabag_render_linklist($data, $conf); $link = $data['links'][0]; // data shouldn't be altered $this->assertEquals($str, $data['title']); @@ -49,4 +51,3 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL'))); } } - -- cgit v1.2.3 From 7fde6de1212323418401c15efba06026c704ca87 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 14 Oct 2016 13:22:58 +0200 Subject: 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. --- tests/plugins/PluginWallabagTest.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tests/plugins/PluginWallabagTest.php') diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php index 302ee296..2c268cbd 100644 --- a/tests/plugins/PluginWallabagTest.php +++ b/tests/plugins/PluginWallabagTest.php @@ -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. */ -- cgit v1.2.3