aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/PluginQrcodeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/PluginQrcodeTest.php')
-rw-r--r--tests/plugins/PluginQrcodeTest.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/plugins/PluginQrcodeTest.php b/tests/plugins/PluginQrcodeTest.php
new file mode 100644
index 00000000..ebfadddf
--- /dev/null
+++ b/tests/plugins/PluginQrcodeTest.php
@@ -0,0 +1,66 @@
1<?php
2/**
3 * PluginQrcodeTest.php
4 */
5
6require_once 'plugins/qrcode/qrcode.php';
7require_once 'application/Router.php';
8
9/**
10 * Class PluginQrcodeTest
11 * Unit test for the QR-Code plugin
12 */
13class PluginQrcodeTest extends PHPUnit_Framework_TestCase
14{
15 /**
16 * Reset plugin path
17 */
18 public function setUp() {
19 PluginManager::$PLUGINS_PATH = 'plugins';
20 }
21
22 /**
23 * Test render_linklist hook.
24 */
25 public function testQrcodeLinklist()
26 {
27 $str = 'http://randomstr.com/test';
28 $data = array(
29 'title' => $str,
30 'links' => array(
31 array(
32 'url' => $str,
33 )
34 )
35 );
36
37 $data = hook_qrcode_render_linklist($data);
38 $link = $data['links'][0];
39 // data shouldn't be altered
40 $this->assertEquals($str, $data['title']);
41 $this->assertEquals($str, $link['url']);
42
43 // plugin data
44 $this->assertEquals(1, count($link['link_plugin']));
45 $this->assertNotFalse(strpos($link['link_plugin'][0], $str));
46 }
47
48 /**
49 * Test render_footer hook.
50 */
51 public function testQrcodeFooter()
52 {
53 $str = 'stuff';
54 $data = array($str => $str);
55 $data['_PAGE_'] = Router::$PAGE_LINKLIST;
56
57 $data = hook_qrcode_render_footer($data);
58 $this->assertEquals($str, $data[$str]);
59 $this->assertEquals(1, count($data['js_files']));
60
61 $data = array($str => $str);
62 $data['_PAGE_'] = $str;
63 $this->assertEquals($str, $data[$str]);
64 $this->assertArrayNotHasKey('js_files', $data);
65 }
66}