aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/PluginManagerTest.php34
-rw-r--r--tests/plugins/PluginReadityourselfTest.php10
-rw-r--r--tests/plugins/PluginWallabagTest.php7
3 files changed, 29 insertions, 22 deletions
diff --git a/tests/PluginManagerTest.php b/tests/PluginManagerTest.php
index 348082c7..61efce68 100644
--- a/tests/PluginManagerTest.php
+++ b/tests/PluginManagerTest.php
@@ -24,29 +24,38 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase
24 private static $pluginName = 'test'; 24 private static $pluginName = 'test';
25 25
26 /** 26 /**
27 * @var PluginManager $pluginManager Plugin Mananger instance.
28 */
29 protected $pluginManager;
30
31 public function setUp()
32 {
33 $conf = new ConfigManager('');
34 $this->pluginManager = new PluginManager($conf);
35 }
36
37 /**
27 * Test plugin loading and hook execution. 38 * Test plugin loading and hook execution.
28 * 39 *
29 * @return void 40 * @return void
30 */ 41 */
31 public function testPlugin() 42 public function testPlugin()
32 { 43 {
33 $pluginManager = PluginManager::getInstance();
34
35 PluginManager::$PLUGINS_PATH = self::$pluginPath; 44 PluginManager::$PLUGINS_PATH = self::$pluginPath;
36 $pluginManager->load(array(self::$pluginName)); 45 $this->pluginManager->load(array(self::$pluginName));
37 46
38 $this->assertTrue(function_exists('hook_test_random')); 47 $this->assertTrue(function_exists('hook_test_random'));
39 48
40 $data = array(0 => 'woot'); 49 $data = array(0 => 'woot');
41 $pluginManager->executeHooks('random', $data); 50 $this->pluginManager->executeHooks('random', $data);
42 $this->assertEquals('woot', $data[1]); 51 $this->assertEquals('woot', $data[1]);
43 52
44 $data = array(0 => 'woot'); 53 $data = array(0 => 'woot');
45 $pluginManager->executeHooks('random', $data, array('target' => 'test')); 54 $this->pluginManager->executeHooks('random', $data, array('target' => 'test'));
46 $this->assertEquals('page test', $data[1]); 55 $this->assertEquals('page test', $data[1]);
47 56
48 $data = array(0 => 'woot'); 57 $data = array(0 => 'woot');
49 $pluginManager->executeHooks('random', $data, array('loggedin' => true)); 58 $this->pluginManager->executeHooks('random', $data, array('loggedin' => true));
50 $this->assertEquals('loggedin', $data[1]); 59 $this->assertEquals('loggedin', $data[1]);
51 } 60 }
52 61
@@ -57,11 +66,8 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase
57 */ 66 */
58 public function testPluginNotFound() 67 public function testPluginNotFound()
59 { 68 {
60 $pluginManager = PluginManager::getInstance(); 69 $this->pluginManager->load(array());
61 70 $this->pluginManager->load(array('nope', 'renope'));
62 $pluginManager->load(array());
63
64 $pluginManager->load(array('nope', 'renope'));
65 } 71 }
66 72
67 /** 73 /**
@@ -69,16 +75,14 @@ class PluginManagerTest extends PHPUnit_Framework_TestCase
69 */ 75 */
70 public function testGetPluginsMeta() 76 public function testGetPluginsMeta()
71 { 77 {
72 $pluginManager = PluginManager::getInstance();
73
74 PluginManager::$PLUGINS_PATH = self::$pluginPath; 78 PluginManager::$PLUGINS_PATH = self::$pluginPath;
75 $pluginManager->load(array(self::$pluginName)); 79 $this->pluginManager->load(array(self::$pluginName));
76 80
77 $expectedParameters = array( 81 $expectedParameters = array(
78 'pop' => '', 82 'pop' => '',
79 'hip' => '', 83 'hip' => '',
80 ); 84 );
81 $meta = $pluginManager->getPluginsMeta(); 85 $meta = $this->pluginManager->getPluginsMeta();
82 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']); 86 $this->assertEquals('test plugin', $meta[self::$pluginName]['description']);
83 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']); 87 $this->assertEquals($expectedParameters, $meta[self::$pluginName]['parameters']);
84 } 88 }
diff --git a/tests/plugins/PluginReadityourselfTest.php b/tests/plugins/PluginReadityourselfTest.php
index bc5da042..d73e666a 100644
--- a/tests/plugins/PluginReadityourselfTest.php
+++ b/tests/plugins/PluginReadityourselfTest.php
@@ -4,6 +4,8 @@
4 * PluginReadityourselfTest.php.php 4 * PluginReadityourselfTest.php.php
5 */ 5 */
6 6
7// FIXME! add an init method.
8$conf = new ConfigManager('');
7require_once 'plugins/readityourself/readityourself.php'; 9require_once 'plugins/readityourself/readityourself.php';
8 10
9/** 11/**
@@ -25,7 +27,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
25 */ 27 */
26 function testReadityourselfLinklist() 28 function testReadityourselfLinklist()
27 { 29 {
28 $conf = ConfigManager::getInstance(); 30 $conf = new ConfigManager('');
29 $conf->set('plugins.READITYOUSELF_URL', 'value'); 31 $conf->set('plugins.READITYOUSELF_URL', 'value');
30 $str = 'http://randomstr.com/test'; 32 $str = 'http://randomstr.com/test';
31 $data = array( 33 $data = array(
@@ -37,7 +39,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
37 ) 39 )
38 ); 40 );
39 41
40 $data = hook_readityourself_render_linklist($data); 42 $data = hook_readityourself_render_linklist($data, $conf);
41 $link = $data['links'][0]; 43 $link = $data['links'][0];
42 // data shouldn't be altered 44 // data shouldn't be altered
43 $this->assertEquals($str, $data['title']); 45 $this->assertEquals($str, $data['title']);
@@ -53,7 +55,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
53 */ 55 */
54 function testReadityourselfLinklistWithoutConfig() 56 function testReadityourselfLinklistWithoutConfig()
55 { 57 {
56 $conf = ConfigManager::getInstance(); 58 $conf = new ConfigManager('');
57 $conf->set('plugins.READITYOUSELF_URL', null); 59 $conf->set('plugins.READITYOUSELF_URL', null);
58 $str = 'http://randomstr.com/test'; 60 $str = 'http://randomstr.com/test';
59 $data = array( 61 $data = array(
@@ -65,7 +67,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
65 ) 67 )
66 ); 68 );
67 69
68 $data = hook_readityourself_render_linklist($data); 70 $data = hook_readityourself_render_linklist($data, $conf);
69 $link = $data['links'][0]; 71 $link = $data['links'][0];
70 // data shouldn't be altered 72 // data shouldn't be altered
71 $this->assertEquals($str, $data['title']); 73 $this->assertEquals($str, $data['title']);
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 @@
4 * PluginWallabagTest.php.php 4 * PluginWallabagTest.php.php
5 */ 5 */
6 6
7// FIXME! add an init method.
8$conf = new ConfigManager('');
7require_once 'plugins/wallabag/wallabag.php'; 9require_once 'plugins/wallabag/wallabag.php';
8 10
9/** 11/**
@@ -25,7 +27,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
25 */ 27 */
26 function testWallabagLinklist() 28 function testWallabagLinklist()
27 { 29 {
28 $conf = ConfigManager::getInstance(); 30 $conf = new ConfigManager('');
29 $conf->set('plugins.WALLABAG_URL', 'value'); 31 $conf->set('plugins.WALLABAG_URL', 'value');
30 $str = 'http://randomstr.com/test'; 32 $str = 'http://randomstr.com/test';
31 $data = array( 33 $data = array(
@@ -37,7 +39,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
37 ) 39 )
38 ); 40 );
39 41
40 $data = hook_wallabag_render_linklist($data); 42 $data = hook_wallabag_render_linklist($data, $conf);
41 $link = $data['links'][0]; 43 $link = $data['links'][0];
42 // data shouldn't be altered 44 // data shouldn't be altered
43 $this->assertEquals($str, $data['title']); 45 $this->assertEquals($str, $data['title']);
@@ -49,4 +51,3 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase
49 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL'))); 51 $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL')));
50 } 52 }
51} 53}
52