aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/PluginAddlinkTest.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2015-11-08 13:29:32 +0100
committerArthur <arthur@hoa.ro>2015-11-08 13:29:32 +0100
commitfd006c630b64146edc402b68d8503c716f8a55d6 (patch)
treee53904cc6232c7f2fe8e1de6f23c9a5d6c5403ad /tests/plugins/PluginAddlinkTest.php
parent70df947af60afb05529024bb2d3825eaf6cc7950 (diff)
parent056107ab4eae0a4867cf8d55de77d31f8868b899 (diff)
downloadShaarli-fd006c630b64146edc402b68d8503c716f8a55d6.tar.gz
Shaarli-fd006c630b64146edc402b68d8503c716f8a55d6.tar.zst
Shaarli-fd006c630b64146edc402b68d8503c716f8a55d6.zip
Merge pull request #275 from shaarli/plugin-proposition
Plugin proposition
Diffstat (limited to 'tests/plugins/PluginAddlinkTest.php')
-rw-r--r--tests/plugins/PluginAddlinkTest.php100
1 files changed, 100 insertions, 0 deletions
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}