aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/plugins/PlugQrcodeTest.php67
-rw-r--r--tests/plugins/PluginAddlinkTest.php100
-rw-r--r--tests/plugins/PluginArchiveorgTest.php48
-rw-r--r--tests/plugins/PluginPlayvideosTest.php61
-rw-r--r--tests/plugins/PluginReadityourselfTest.php75
5 files changed, 351 insertions, 0 deletions
diff --git a/tests/plugins/PlugQrcodeTest.php b/tests/plugins/PlugQrcodeTest.php
new file mode 100644
index 00000000..86dc7f29
--- /dev/null
+++ b/tests/plugins/PlugQrcodeTest.php
@@ -0,0 +1,67 @@
1<?php
2
3/**
4 * PlugQrcodeTest.php
5 */
6
7require_once 'plugins/qrcode/qrcode.php';
8require_once 'application/Router.php';
9
10/**
11 * Class PlugQrcodeTest
12 * Unit test for the QR-Code plugin
13 */
14class PlugQrcodeTest extends PHPUnit_Framework_TestCase
15{
16 /**
17 * Reset plugin path
18 */
19 function setUp() {
20 PluginManager::$PLUGINS_PATH = 'plugins';
21 }
22
23 /**
24 * Test render_linklist hook.
25 */
26 function testQrcodeLinklist()
27 {
28 $str = 'http://randomstr.com/test';
29 $data = array(
30 'title' => $str,
31 'links' => array(
32 array(
33 'url' => $str,
34 )
35 )
36 );
37
38 $data = hook_qrcode_render_linklist($data);
39 $link = $data['links'][0];
40 // data shouldn't be altered
41 $this->assertEquals($str, $data['title']);
42 $this->assertEquals($str, $link['url']);
43
44 // plugin data
45 $this->assertEquals(1, count($link['link_plugin']));
46 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
47 }
48
49 /**
50 * Test render_footer hook.
51 */
52 function testQrcodeFooter()
53 {
54 $str = 'stuff';
55 $data = array($str => $str);
56 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
57
58 $data = hook_qrcode_render_footer($data);
59 $this->assertEquals($str, $data[$str]);
60 $this->assertEquals(1, count($data['js_files']));
61
62 $data = array($str => $str);
63 $data['_PAGE_'] = $str;
64 $this->assertEquals($str, $data[$str]);
65 $this->assertArrayNotHasKey('js_files', $data);
66 }
67}
diff --git a/tests/plugins/PluginAddlinkTest.php b/tests/plugins/PluginAddlinkTest.php
new file mode 100644
index 00000000..a2f25bec
--- /dev/null
+++ b/tests/plugins/PluginAddlinkTest.php
@@ -0,0 +1,100 @@
1<?php
2
3/**
4 * PluginPlayvideosTest.php
5 */
6
7require_once 'plugins/addlink_toolbar/addlink_toolbar.php';
8require_once 'application/Router.php';
9
10/**
11 * Class PluginAddlinkTest
12 * Unit test for the Addlink toolbar plugin
13 */
14class PluginAddlinkTest extends PHPUnit_Framework_TestCase
15{
16 /**
17 * Reset plugin path.
18 */
19 function setUp()
20 {
21 PluginManager::$PLUGINS_PATH = 'plugins';
22 }
23
24 /**
25 * Test render_header hook while logged in.
26 */
27 function testAddlinkHeaderLoggedIn()
28 {
29 $str = 'stuff';
30 $data = array($str => $str);
31 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
32 $data['_LOGGEDIN_'] = true;
33
34 $data = hook_addlink_toolbar_render_header($data);
35 $this->assertEquals($str, $data[$str]);
36 $this->assertEquals(1, count($data['fields_toolbar']));
37
38 $data = array($str => $str);
39 $data['_PAGE_'] = $str;
40 $data['_LOGGEDIN_'] = true;
41 $data = hook_addlink_toolbar_render_header($data);
42 $this->assertEquals($str, $data[$str]);
43 $this->assertArrayNotHasKey('fields_toolbar', $data);
44 }
45
46 /**
47 * Test render_header hook while logged out.
48 */
49 function testAddlinkHeaderLoggedOut()
50 {
51 $str = 'stuff';
52 $data = array($str => $str);
53 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
54 $data['_LOGGEDIN_'] = false;
55
56 $data = hook_addlink_toolbar_render_header($data);
57 $this->assertEquals($str, $data[$str]);
58 $this->assertArrayNotHasKey('fields_toolbar', $data);
59 }
60
61 /**
62 * Test render_includes hook while logged in.
63 */
64 function testAddlinkIncludesLoggedIn()
65 {
66 $str = 'stuff';
67 $data = array($str => $str);
68 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
69 $data['_LOGGEDIN_'] = true;
70
71 $data = hook_addlink_toolbar_render_includes($data);
72 $this->assertEquals($str, $data[$str]);
73 $this->assertEquals(1, count($data['css_files']));
74
75 $str = 'stuff';
76 $data = array($str => $str);
77 $data['_PAGE_'] = $str;
78 $data['_LOGGEDIN_'] = true;
79
80 $data = hook_addlink_toolbar_render_includes($data);
81 $this->assertEquals($str, $data[$str]);
82 $this->assertArrayNotHasKey('css_files', $data);
83 }
84
85 /**
86 * Test render_includes hook.
87 * Should not affect css files while logged out.
88 */
89 function testAddlinkIncludesLoggedOut()
90 {
91 $str = 'stuff';
92 $data = array($str => $str);
93 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
94 $data['_LOGGEDIN_'] = false;
95
96 $data = hook_addlink_toolbar_render_includes($data);
97 $this->assertEquals($str, $data[$str]);
98 $this->assertArrayNotHasKey('css_files', $data);
99 }
100}
diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php
new file mode 100644
index 00000000..dbc52bc8
--- /dev/null
+++ b/tests/plugins/PluginArchiveorgTest.php
@@ -0,0 +1,48 @@
1<?php
2
3/**
4 * PluginArchiveorgTest.php
5 */
6
7require_once 'plugins/archiveorg/archiveorg.php';
8
9/**
10 * Class PlugQrcodeTest
11 * Unit test for the QR-Code plugin
12 */
13class PluginArchiveorgTest extends PHPUnit_Framework_TestCase
14{
15 /**
16 * Reset plugin path
17 */
18 function setUp()
19 {
20 PluginManager::$PLUGINS_PATH = 'plugins';
21 }
22
23 /**
24 * Test render_linklist hook.
25 */
26 function testArchiveorgLinklist()
27 {
28 $str = 'http://randomstr.com/test';
29 $data = array(
30 'title' => $str,
31 'links' => array(
32 array(
33 'url' => $str,
34 )
35 )
36 );
37
38 $data = hook_archiveorg_render_linklist($data);
39 $link = $data['links'][0];
40 // data shouldn't be altered
41 $this->assertEquals($str, $data['title']);
42 $this->assertEquals($str, $link['url']);
43
44 // plugin data
45 $this->assertEquals(1, count($link['link_plugin']));
46 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
47 }
48}
diff --git a/tests/plugins/PluginPlayvideosTest.php b/tests/plugins/PluginPlayvideosTest.php
new file mode 100644
index 00000000..be1ef774
--- /dev/null
+++ b/tests/plugins/PluginPlayvideosTest.php
@@ -0,0 +1,61 @@
1<?php
2
3/**
4 * PluginPlayvideosTest.php
5 */
6
7require_once 'plugins/playvideos/playvideos.php';
8require_once 'application/Router.php';
9
10/**
11 * Class PluginPlayvideosTest
12 * Unit test for the PlayVideos plugin
13 */
14class PluginPlayvideosTest extends PHPUnit_Framework_TestCase
15{
16 /**
17 * Reset plugin path
18 */
19 function setUp()
20 {
21 PluginManager::$PLUGINS_PATH = 'plugins';
22 }
23
24 /**
25 * Test render_linklist hook.
26 */
27 function testPlayvideosHeader()
28 {
29 $str = 'stuff';
30 $data = array($str => $str);
31 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
32
33 $data = hook_playvideos_render_header($data);
34 $this->assertEquals($str, $data[$str]);
35 $this->assertEquals(1, count($data['buttons_toolbar']));
36
37 $data = array($str => $str);
38 $data['_PAGE_'] = $str;
39 $this->assertEquals($str, $data[$str]);
40 $this->assertArrayNotHasKey('buttons_toolbar', $data);
41 }
42
43 /**
44 * Test render_footer hook.
45 */
46 function testPlayvideosFooter()
47 {
48 $str = 'stuff';
49 $data = array($str => $str);
50 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
51
52 $data = hook_playvideos_render_footer($data);
53 $this->assertEquals($str, $data[$str]);
54 $this->assertEquals(2, count($data['js_files']));
55
56 $data = array($str => $str);
57 $data['_PAGE_'] = $str;
58 $this->assertEquals($str, $data[$str]);
59 $this->assertArrayNotHasKey('js_files', $data);
60 }
61}
diff --git a/tests/plugins/PluginReadityourselfTest.php b/tests/plugins/PluginReadityourselfTest.php
new file mode 100644
index 00000000..8bf17bf1
--- /dev/null
+++ b/tests/plugins/PluginReadityourselfTest.php
@@ -0,0 +1,75 @@
1<?php
2
3/**
4 * PluginReadityourselfTest.php.php
5 */
6
7require_once 'plugins/readityourself/readityourself.php';
8
9/**
10 * Class PluginWallabagTest
11 * Unit test for the Wallabag plugin
12 */
13class PluginReadityourselfTest extends PHPUnit_Framework_TestCase
14{
15 /**
16 * Reset plugin path
17 */
18 function setUp()
19 {
20 PluginManager::$PLUGINS_PATH = 'plugins';
21 }
22
23 /**
24 * Test render_linklist hook.
25 */
26 function testReadityourselfLinklist()
27 {
28 $GLOBALS['plugins']['READITYOUSELF_URL'] = 'value';
29 $str = 'http://randomstr.com/test';
30 $data = array(
31 'title' => $str,
32 'links' => array(
33 array(
34 'url' => $str,
35 )
36 )
37 );
38
39 $data = hook_readityourself_render_linklist($data);
40 $link = $data['links'][0];
41 // data shouldn't be altered
42 $this->assertEquals($str, $data['title']);
43 $this->assertEquals($str, $link['url']);
44
45 // plugin data
46 $this->assertEquals(1, count($link['link_plugin']));
47 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
48 }
49
50 /**
51 * Test without config: nothing should happened.
52 */
53 function testReadityourselfLinklistWithoutConfig()
54 {
55 unset($GLOBALS['plugins']['READITYOUSELF_URL']);
56 $str = 'http://randomstr.com/test';
57 $data = array(
58 'title' => $str,
59 'links' => array(
60 array(
61 'url' => $str,
62 )
63 )
64 );
65
66 $data = hook_readityourself_render_linklist($data);
67 $link = $data['links'][0];
68 // data shouldn't be altered
69 $this->assertEquals($str, $data['title']);
70 $this->assertEquals($str, $link['url']);
71
72 // plugin data
73 $this->assertArrayNotHasKey('link_plugin', $link);
74 }
75}