aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/PlugQrcodeTest.php67
-rw-r--r--tests/plugins/PluginArchiveorgTest.php48
-rw-r--r--tests/plugins/PluginPlayvideosTest.php61
3 files changed, 176 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/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}