diff options
Diffstat (limited to 'tests/plugins')
-rw-r--r-- | tests/plugins/PluginArchiveorgTest.php | 102 | ||||
-rw-r--r-- | tests/plugins/PluginIssoTest.php | 151 | ||||
-rw-r--r-- | tests/plugins/PluginMarkdownTest.php | 99 | ||||
-rw-r--r-- | tests/plugins/PluginReadityourselfTest.php | 31 | ||||
-rw-r--r-- | tests/plugins/PluginWallabagTest.php | 29 | ||||
-rw-r--r-- | tests/plugins/resources/markdown.html | 24 | ||||
-rw-r--r-- | tests/plugins/resources/markdown.md | 24 | ||||
-rw-r--r-- | tests/plugins/test/test.meta | 4 |
8 files changed, 442 insertions, 22 deletions
diff --git a/tests/plugins/PluginArchiveorgTest.php b/tests/plugins/PluginArchiveorgTest.php index dbc52bc8..4daa4c9d 100644 --- a/tests/plugins/PluginArchiveorgTest.php +++ b/tests/plugins/PluginArchiveorgTest.php | |||
@@ -7,8 +7,8 @@ | |||
7 | require_once 'plugins/archiveorg/archiveorg.php'; | 7 | require_once 'plugins/archiveorg/archiveorg.php'; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Class PlugQrcodeTest | 10 | * Class PluginArchiveorgTest |
11 | * Unit test for the QR-Code plugin | 11 | * Unit test for the archiveorg plugin |
12 | */ | 12 | */ |
13 | class PluginArchiveorgTest extends PHPUnit_Framework_TestCase | 13 | class PluginArchiveorgTest extends PHPUnit_Framework_TestCase |
14 | { | 14 | { |
@@ -21,21 +21,25 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase | |||
21 | } | 21 | } |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Test render_linklist hook. | 24 | * Test render_linklist hook on external links. |
25 | */ | 25 | */ |
26 | function testArchiveorgLinklist() | 26 | function testArchiveorgLinklistOnExternalLinks() |
27 | { | 27 | { |
28 | $str = 'http://randomstr.com/test'; | 28 | $str = 'http://randomstr.com/test'; |
29 | |||
29 | $data = array( | 30 | $data = array( |
30 | 'title' => $str, | 31 | 'title' => $str, |
31 | 'links' => array( | 32 | 'links' => array( |
32 | array( | 33 | array( |
33 | 'url' => $str, | 34 | 'url' => $str, |
35 | 'private' => 0, | ||
36 | 'real_url' => $str | ||
34 | ) | 37 | ) |
35 | ) | 38 | ) |
36 | ); | 39 | ); |
37 | 40 | ||
38 | $data = hook_archiveorg_render_linklist($data); | 41 | $data = hook_archiveorg_render_linklist($data); |
42 | |||
39 | $link = $data['links'][0]; | 43 | $link = $data['links'][0]; |
40 | // data shouldn't be altered | 44 | // data shouldn't be altered |
41 | $this->assertEquals($str, $data['title']); | 45 | $this->assertEquals($str, $data['title']); |
@@ -44,5 +48,95 @@ class PluginArchiveorgTest extends PHPUnit_Framework_TestCase | |||
44 | // plugin data | 48 | // plugin data |
45 | $this->assertEquals(1, count($link['link_plugin'])); | 49 | $this->assertEquals(1, count($link['link_plugin'])); |
46 | $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); | 50 | $this->assertNotFalse(strpos($link['link_plugin'][0], $str)); |
51 | |||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Test render_linklist hook on internal links. | ||
56 | */ | ||
57 | function testArchiveorgLinklistOnInternalLinks() | ||
58 | { | ||
59 | $internalLink1 = 'http://shaarli.shaarli/?qvMAqg'; | ||
60 | $internalLinkRealURL1 = '?qvMAqg'; | ||
61 | |||
62 | $internalLink2 = 'http://shaarli.shaarli/?2_7zww'; | ||
63 | $internalLinkRealURL2 = '?2_7zww'; | ||
64 | |||
65 | $internalLink3 = 'http://shaarli.shaarli/?z7u-_Q'; | ||
66 | $internalLinkRealURL3 = '?z7u-_Q'; | ||
67 | |||
68 | $data = array( | ||
69 | 'title' => $internalLink1, | ||
70 | 'links' => array( | ||
71 | array( | ||
72 | 'url' => $internalLink1, | ||
73 | 'private' => 0, | ||
74 | 'real_url' => $internalLinkRealURL1 | ||
75 | ), | ||
76 | array( | ||
77 | 'url' => $internalLink1, | ||
78 | 'private' => 1, | ||
79 | 'real_url' => $internalLinkRealURL1 | ||
80 | ), | ||
81 | array( | ||
82 | 'url' => $internalLink2, | ||
83 | 'private' => 0, | ||
84 | 'real_url' => $internalLinkRealURL2 | ||
85 | ), | ||
86 | array( | ||
87 | 'url' => $internalLink2, | ||
88 | 'private' => 1, | ||
89 | 'real_url' => $internalLinkRealURL2 | ||
90 | ), | ||
91 | array( | ||
92 | 'url' => $internalLink3, | ||
93 | 'private' => 0, | ||
94 | 'real_url' => $internalLinkRealURL3 | ||
95 | ), | ||
96 | array( | ||
97 | 'url' => $internalLink3, | ||
98 | 'private' => 1, | ||
99 | 'real_url' => $internalLinkRealURL3 | ||
100 | ) | ||
101 | ) | ||
102 | ); | ||
103 | |||
104 | |||
105 | $data = hook_archiveorg_render_linklist($data); | ||
106 | |||
107 | // Case n°1: first link type, public | ||
108 | $link = $data['links'][0]; | ||
109 | |||
110 | $this->assertEquals(1, count($link['link_plugin'])); | ||
111 | $this->assertNotFalse(strpos($link['link_plugin'][0], $internalLink1)); | ||
112 | |||
113 | // Case n°2: first link type, private | ||
114 | $link = $data['links'][1]; | ||
115 | |||
116 | $this->assertArrayNotHasKey('link_plugin', $link); | ||
117 | |||
118 | // Case n°3: second link type, public | ||
119 | $link = $data['links'][2]; | ||
120 | |||
121 | $this->assertEquals(1, count($link['link_plugin'])); | ||
122 | $this->assertNotFalse(strpos($link['link_plugin'][0], $internalLink2)); | ||
123 | |||
124 | // Case n°4: second link type, private | ||
125 | $link = $data['links'][3]; | ||
126 | |||
127 | $this->assertArrayNotHasKey('link_plugin', $link); | ||
128 | |||
129 | // Case n°5: third link type, public | ||
130 | $link = $data['links'][4]; | ||
131 | |||
132 | $this->assertEquals(1, count($link['link_plugin'])); | ||
133 | $this->assertNotFalse(strpos($link['link_plugin'][0], $internalLink3)); | ||
134 | |||
135 | // Case n°6: third link type, private | ||
136 | $link = $data['links'][5]; | ||
137 | |||
138 | $this->assertArrayNotHasKey('link_plugin', $link); | ||
139 | |||
47 | } | 140 | } |
141 | |||
48 | } | 142 | } |
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php new file mode 100644 index 00000000..6b7904dd --- /dev/null +++ b/tests/plugins/PluginIssoTest.php | |||
@@ -0,0 +1,151 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'plugins/isso/isso.php'; | ||
4 | |||
5 | /** | ||
6 | * Class PluginIssoTest | ||
7 | * | ||
8 | * Test the Isso plugin (comment system). | ||
9 | */ | ||
10 | class PluginIssoTest extends PHPUnit_Framework_TestCase | ||
11 | { | ||
12 | /** | ||
13 | * Reset plugin path | ||
14 | */ | ||
15 | function setUp() | ||
16 | { | ||
17 | PluginManager::$PLUGINS_PATH = 'plugins'; | ||
18 | } | ||
19 | |||
20 | /** | ||
21 | * Test Isso init without errors. | ||
22 | */ | ||
23 | function testWallabagInitNoError() | ||
24 | { | ||
25 | $conf = new ConfigManager(''); | ||
26 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
27 | $errors = isso_init($conf); | ||
28 | $this->assertEmpty($errors); | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * Test Isso init with errors. | ||
33 | */ | ||
34 | function testWallabagInitError() | ||
35 | { | ||
36 | $conf = new ConfigManager(''); | ||
37 | $errors = isso_init($conf); | ||
38 | $this->assertNotEmpty($errors); | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * Test render_linklist hook with valid settings to display the comment form. | ||
43 | */ | ||
44 | function testIssoDisplayed() | ||
45 | { | ||
46 | $conf = new ConfigManager(''); | ||
47 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
48 | |||
49 | $str = 'http://randomstr.com/test'; | ||
50 | $date = '20161118_100001'; | ||
51 | $data = array( | ||
52 | 'title' => $str, | ||
53 | 'links' => array( | ||
54 | array( | ||
55 | 'id' => 12, | ||
56 | 'url' => $str, | ||
57 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date), | ||
58 | ) | ||
59 | ) | ||
60 | ); | ||
61 | |||
62 | $data = hook_isso_render_linklist($data, $conf); | ||
63 | |||
64 | // data shouldn't be altered | ||
65 | $this->assertEquals($str, $data['title']); | ||
66 | $this->assertEquals($str, $data['links'][0]['url']); | ||
67 | |||
68 | // plugin data | ||
69 | $this->assertEquals(1, count($data['plugin_end_zone'])); | ||
70 | $this->assertNotFalse(strpos( | ||
71 | $data['plugin_end_zone'][0], | ||
72 | 'data-isso-id="'. $data['links'][0]['id'] .'"' | ||
73 | )); | ||
74 | $this->assertNotFalse(strpos( | ||
75 | $data['plugin_end_zone'][0], | ||
76 | 'data-title="'. $data['links'][0]['id'] .'"' | ||
77 | )); | ||
78 | $this->assertNotFalse(strpos($data['plugin_end_zone'][0], 'embed.min.js')); | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * Test isso plugin when multiple links are displayed (shouldn't be displayed). | ||
83 | */ | ||
84 | function testIssoMultipleLinks() | ||
85 | { | ||
86 | $conf = new ConfigManager(''); | ||
87 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
88 | |||
89 | $str = 'http://randomstr.com/test'; | ||
90 | $date1 = '20161118_100001'; | ||
91 | $date2 = '20161118_100002'; | ||
92 | $data = array( | ||
93 | 'title' => $str, | ||
94 | 'links' => array( | ||
95 | array( | ||
96 | 'id' => 12, | ||
97 | 'url' => $str, | ||
98 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date1), | ||
99 | ), | ||
100 | array( | ||
101 | 'id' => 13, | ||
102 | 'url' => $str . '2', | ||
103 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date2), | ||
104 | ), | ||
105 | ) | ||
106 | ); | ||
107 | |||
108 | $processed = hook_isso_render_linklist($data, $conf); | ||
109 | // data shouldn't be altered | ||
110 | $this->assertEquals($data, $processed); | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * Test isso plugin when using search (shouldn't be displayed). | ||
115 | */ | ||
116 | function testIssoNotDisplayedWhenSearch() | ||
117 | { | ||
118 | $conf = new ConfigManager(''); | ||
119 | $conf->set('plugins.ISSO_SERVER', 'value'); | ||
120 | |||
121 | $str = 'http://randomstr.com/test'; | ||
122 | $date = '20161118_100001'; | ||
123 | $data = array( | ||
124 | 'title' => $str, | ||
125 | 'links' => array( | ||
126 | array( | ||
127 | 'id' => 12, | ||
128 | 'url' => $str, | ||
129 | 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date), | ||
130 | ) | ||
131 | ), | ||
132 | 'search_term' => $str | ||
133 | ); | ||
134 | |||
135 | $processed = hook_isso_render_linklist($data, $conf); | ||
136 | |||
137 | // data shouldn't be altered | ||
138 | $this->assertEquals($data, $processed); | ||
139 | } | ||
140 | |||
141 | /** | ||
142 | * Test isso plugin without server configuration (shouldn't be displayed). | ||
143 | */ | ||
144 | function testIssoWithoutConf() | ||
145 | { | ||
146 | $data = 'abc'; | ||
147 | $conf = new ConfigManager(''); | ||
148 | $processed = hook_isso_render_linklist($data, $conf); | ||
149 | $this->assertEquals($data, $processed); | ||
150 | } | ||
151 | } | ||
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php index fa7e1d52..f1e1acf8 100644 --- a/tests/plugins/PluginMarkdownTest.php +++ b/tests/plugins/PluginMarkdownTest.php | |||
@@ -8,17 +8,23 @@ require_once 'application/Utils.php'; | |||
8 | require_once 'plugins/markdown/markdown.php'; | 8 | require_once 'plugins/markdown/markdown.php'; |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Class PlugQrcodeTest | 11 | * Class PluginMarkdownTest |
12 | * Unit test for the QR-Code plugin | 12 | * Unit test for the Markdown plugin |
13 | */ | 13 | */ |
14 | class PluginMarkdownTest extends PHPUnit_Framework_TestCase | 14 | class PluginMarkdownTest extends PHPUnit_Framework_TestCase |
15 | { | 15 | { |
16 | /** | 16 | /** |
17 | * @var ConfigManager instance. | ||
18 | */ | ||
19 | protected $conf; | ||
20 | |||
21 | /** | ||
17 | * Reset plugin path | 22 | * Reset plugin path |
18 | */ | 23 | */ |
19 | function setUp() | 24 | function setUp() |
20 | { | 25 | { |
21 | PluginManager::$PLUGINS_PATH = 'plugins'; | 26 | PluginManager::$PLUGINS_PATH = 'plugins'; |
27 | $this->conf = new ConfigManager('tests/utils/config/configJson'); | ||
22 | } | 28 | } |
23 | 29 | ||
24 | /** | 30 | /** |
@@ -36,7 +42,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
36 | ), | 42 | ), |
37 | ); | 43 | ); |
38 | 44 | ||
39 | $data = hook_markdown_render_linklist($data); | 45 | $data = hook_markdown_render_linklist($data, $this->conf); |
40 | $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>')); | 46 | $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>')); |
41 | $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>')); | 47 | $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>')); |
42 | } | 48 | } |
@@ -61,7 +67,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
61 | ), | 67 | ), |
62 | ); | 68 | ); |
63 | 69 | ||
64 | $data = hook_markdown_render_daily($data); | 70 | $data = hook_markdown_render_daily($data, $this->conf); |
65 | $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<h1>')); | 71 | $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<h1>')); |
66 | $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<p>')); | 72 | $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<p>')); |
67 | } | 73 | } |
@@ -110,6 +116,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
110 | $output = escape($input); | 116 | $output = escape($input); |
111 | $input .= '<a href="#" onmouseHover="alert(\'xss\');" attr="tt">link</a>'; | 117 | $input .= '<a href="#" onmouseHover="alert(\'xss\');" attr="tt">link</a>'; |
112 | $output .= '<a href="#" attr="tt">link</a>'; | 118 | $output .= '<a href="#" attr="tt">link</a>'; |
119 | $input .= '<a href="#" onmouseHover=alert(\'xss\'); attr="tt">link</a>'; | ||
120 | $output .= '<a href="#" attr="tt">link</a>'; | ||
113 | $this->assertEquals($output, sanitize_html($input)); | 121 | $this->assertEquals($output, sanitize_html($input)); |
114 | // Do not touch escaped HTML. | 122 | // Do not touch escaped HTML. |
115 | $input = escape($input); | 123 | $input = escape($input); |
@@ -125,12 +133,16 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
125 | $data = array( | 133 | $data = array( |
126 | 'links' => array(array( | 134 | 'links' => array(array( |
127 | 'description' => $str, | 135 | 'description' => $str, |
128 | 'tags' => NO_MD_TAG | 136 | 'tags' => NO_MD_TAG, |
137 | 'taglist' => array(NO_MD_TAG), | ||
129 | )) | 138 | )) |
130 | ); | 139 | ); |
131 | 140 | ||
132 | $data = hook_markdown_render_linklist($data); | 141 | $processed = hook_markdown_render_linklist($data, $this->conf); |
133 | $this->assertEquals($str, $data['links'][0]['description']); | 142 | $this->assertEquals($str, $processed['links'][0]['description']); |
143 | |||
144 | $processed = hook_markdown_render_feed($data, $this->conf); | ||
145 | $this->assertEquals($str, $processed['links'][0]['description']); | ||
134 | 146 | ||
135 | $data = array( | 147 | $data = array( |
136 | // Columns data | 148 | // Columns data |
@@ -140,13 +152,82 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
140 | // nth link | 152 | // nth link |
141 | 0 => array( | 153 | 0 => array( |
142 | 'formatedDescription' => $str, | 154 | 'formatedDescription' => $str, |
143 | 'tags' => NO_MD_TAG | 155 | 'tags' => NO_MD_TAG, |
156 | 'taglist' => array(), | ||
144 | ), | 157 | ), |
145 | ), | 158 | ), |
146 | ), | 159 | ), |
147 | ); | 160 | ); |
148 | 161 | ||
149 | $data = hook_markdown_render_daily($data); | 162 | $data = hook_markdown_render_daily($data, $this->conf); |
150 | $this->assertEquals($str, $data['cols'][0][0]['formatedDescription']); | 163 | $this->assertEquals($str, $data['cols'][0][0]['formatedDescription']); |
151 | } | 164 | } |
165 | |||
166 | /** | ||
167 | * Test that a close value to nomarkdown is not understand as nomarkdown (previous value `.nomarkdown`). | ||
168 | */ | ||
169 | function testNoMarkdownNotExcactlyMatching() | ||
170 | { | ||
171 | $str = 'All _work_ and `no play` makes Jack a *dull* boy.'; | ||
172 | $data = array( | ||
173 | 'links' => array(array( | ||
174 | 'description' => $str, | ||
175 | 'tags' => '.' . NO_MD_TAG, | ||
176 | 'taglist' => array('.'. NO_MD_TAG), | ||
177 | )) | ||
178 | ); | ||
179 | |||
180 | $data = hook_markdown_render_feed($data, $this->conf); | ||
181 | $this->assertContains('<em>', $data['links'][0]['description']); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Test hashtag links processed with markdown. | ||
186 | */ | ||
187 | function testMarkdownHashtagLinks() | ||
188 | { | ||
189 | $md = file_get_contents('tests/plugins/resources/markdown.md'); | ||
190 | $md = format_description($md); | ||
191 | $html = file_get_contents('tests/plugins/resources/markdown.html'); | ||
192 | |||
193 | $data = process_markdown($md); | ||
194 | $this->assertEquals($html, $data); | ||
195 | } | ||
196 | |||
197 | /** | ||
198 | * Make sure that the HTML tags are escaped. | ||
199 | */ | ||
200 | public function testMarkdownWithHtmlEscape() | ||
201 | { | ||
202 | $md = '**strong** <strong>strong</strong>'; | ||
203 | $html = '<div class="markdown"><p><strong>strong</strong> <strong>strong</strong></p></div>'; | ||
204 | $data = array( | ||
205 | 'links' => array( | ||
206 | 0 => array( | ||
207 | 'description' => $md, | ||
208 | ), | ||
209 | ), | ||
210 | ); | ||
211 | $data = hook_markdown_render_linklist($data, $this->conf); | ||
212 | $this->assertEquals($html, $data['links'][0]['description']); | ||
213 | } | ||
214 | |||
215 | /** | ||
216 | * Make sure that the HTML tags aren't escaped with the setting set to false. | ||
217 | */ | ||
218 | public function testMarkdownWithHtmlNoEscape() | ||
219 | { | ||
220 | $this->conf->set('security.markdown_escape', false); | ||
221 | $md = '**strong** <strong>strong</strong>'; | ||
222 | $html = '<div class="markdown"><p><strong>strong</strong> <strong>strong</strong></p></div>'; | ||
223 | $data = array( | ||
224 | 'links' => array( | ||
225 | 0 => array( | ||
226 | 'description' => $md, | ||
227 | ), | ||
228 | ), | ||
229 | ); | ||
230 | $data = hook_markdown_render_linklist($data, $this->conf); | ||
231 | $this->assertEquals($html, $data['links'][0]['description']); | ||
232 | } | ||
152 | } | 233 | } |
diff --git a/tests/plugins/PluginReadityourselfTest.php b/tests/plugins/PluginReadityourselfTest.php index 8bf17bf1..532db146 100644 --- a/tests/plugins/PluginReadityourselfTest.php +++ b/tests/plugins/PluginReadityourselfTest.php | |||
@@ -21,11 +21,33 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase | |||
21 | } | 21 | } |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Test Readityourself init without errors. | ||
25 | */ | ||
26 | function testReadityourselfInitNoError() | ||
27 | { | ||
28 | $conf = new ConfigManager(''); | ||
29 | $conf->set('plugins.READITYOUSELF_URL', 'value'); | ||
30 | $errors = readityourself_init($conf); | ||
31 | $this->assertEmpty($errors); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * Test Readityourself init with errors. | ||
36 | */ | ||
37 | function testReadityourselfInitError() | ||
38 | { | ||
39 | $conf = new ConfigManager(''); | ||
40 | $errors = readityourself_init($conf); | ||
41 | $this->assertNotEmpty($errors); | ||
42 | } | ||
43 | |||
44 | /** | ||
24 | * Test render_linklist hook. | 45 | * Test render_linklist hook. |
25 | */ | 46 | */ |
26 | function testReadityourselfLinklist() | 47 | function testReadityourselfLinklist() |
27 | { | 48 | { |
28 | $GLOBALS['plugins']['READITYOUSELF_URL'] = 'value'; | 49 | $conf = new ConfigManager(''); |
50 | $conf->set('plugins.READITYOUSELF_URL', 'value'); | ||
29 | $str = 'http://randomstr.com/test'; | 51 | $str = 'http://randomstr.com/test'; |
30 | $data = array( | 52 | $data = array( |
31 | 'title' => $str, | 53 | 'title' => $str, |
@@ -36,7 +58,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase | |||
36 | ) | 58 | ) |
37 | ); | 59 | ); |
38 | 60 | ||
39 | $data = hook_readityourself_render_linklist($data); | 61 | $data = hook_readityourself_render_linklist($data, $conf); |
40 | $link = $data['links'][0]; | 62 | $link = $data['links'][0]; |
41 | // data shouldn't be altered | 63 | // data shouldn't be altered |
42 | $this->assertEquals($str, $data['title']); | 64 | $this->assertEquals($str, $data['title']); |
@@ -52,7 +74,8 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase | |||
52 | */ | 74 | */ |
53 | function testReadityourselfLinklistWithoutConfig() | 75 | function testReadityourselfLinklistWithoutConfig() |
54 | { | 76 | { |
55 | unset($GLOBALS['plugins']['READITYOUSELF_URL']); | 77 | $conf = new ConfigManager(''); |
78 | $conf->set('plugins.READITYOUSELF_URL', null); | ||
56 | $str = 'http://randomstr.com/test'; | 79 | $str = 'http://randomstr.com/test'; |
57 | $data = array( | 80 | $data = array( |
58 | 'title' => $str, | 81 | 'title' => $str, |
@@ -63,7 +86,7 @@ class PluginReadityourselfTest extends PHPUnit_Framework_TestCase | |||
63 | ) | 86 | ) |
64 | ); | 87 | ); |
65 | 88 | ||
66 | $data = hook_readityourself_render_linklist($data); | 89 | $data = hook_readityourself_render_linklist($data, $conf); |
67 | $link = $data['links'][0]; | 90 | $link = $data['links'][0]; |
68 | // data shouldn't be altered | 91 | // data shouldn't be altered |
69 | $this->assertEquals($str, $data['title']); | 92 | $this->assertEquals($str, $data['title']); |
diff --git a/tests/plugins/PluginWallabagTest.php b/tests/plugins/PluginWallabagTest.php index 5d3a60e0..2c268cbd 100644 --- a/tests/plugins/PluginWallabagTest.php +++ b/tests/plugins/PluginWallabagTest.php | |||
@@ -21,11 +21,33 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase | |||
21 | } | 21 | } |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Test wallabag init without errors. | ||
25 | */ | ||
26 | function testWallabagInitNoError() | ||
27 | { | ||
28 | $conf = new ConfigManager(''); | ||
29 | $conf->set('plugins.WALLABAG_URL', 'value'); | ||
30 | $errors = wallabag_init($conf); | ||
31 | $this->assertEmpty($errors); | ||
32 | } | ||
33 | |||
34 | /** | ||
35 | * Test wallabag init with errors. | ||
36 | */ | ||
37 | function testWallabagInitError() | ||
38 | { | ||
39 | $conf = new ConfigManager(''); | ||
40 | $errors = wallabag_init($conf); | ||
41 | $this->assertNotEmpty($errors); | ||
42 | } | ||
43 | |||
44 | /** | ||
24 | * Test render_linklist hook. | 45 | * Test render_linklist hook. |
25 | */ | 46 | */ |
26 | function testWallabagLinklist() | 47 | function testWallabagLinklist() |
27 | { | 48 | { |
28 | $GLOBALS['plugins']['WALLABAG_URL'] = 'value'; | 49 | $conf = new ConfigManager(''); |
50 | $conf->set('plugins.WALLABAG_URL', 'value'); | ||
29 | $str = 'http://randomstr.com/test'; | 51 | $str = 'http://randomstr.com/test'; |
30 | $data = array( | 52 | $data = array( |
31 | 'title' => $str, | 53 | 'title' => $str, |
@@ -36,7 +58,7 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase | |||
36 | ) | 58 | ) |
37 | ); | 59 | ); |
38 | 60 | ||
39 | $data = hook_wallabag_render_linklist($data); | 61 | $data = hook_wallabag_render_linklist($data, $conf); |
40 | $link = $data['links'][0]; | 62 | $link = $data['links'][0]; |
41 | // data shouldn't be altered | 63 | // data shouldn't be altered |
42 | $this->assertEquals($str, $data['title']); | 64 | $this->assertEquals($str, $data['title']); |
@@ -45,7 +67,6 @@ class PluginWallabagTest extends PHPUnit_Framework_TestCase | |||
45 | // plugin data | 67 | // plugin data |
46 | $this->assertEquals(1, count($link['link_plugin'])); | 68 | $this->assertEquals(1, count($link['link_plugin'])); |
47 | $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str))); | 69 | $this->assertNotFalse(strpos($link['link_plugin'][0], urlencode($str))); |
48 | $this->assertNotFalse(strpos($link['link_plugin'][0], $GLOBALS['plugins']['WALLABAG_URL'])); | 70 | $this->assertNotFalse(strpos($link['link_plugin'][0], $conf->get('plugins.WALLABAG_URL'))); |
49 | } | 71 | } |
50 | } | 72 | } |
51 | |||
diff --git a/tests/plugins/resources/markdown.html b/tests/plugins/resources/markdown.html new file mode 100644 index 00000000..07a5a32e --- /dev/null +++ b/tests/plugins/resources/markdown.html | |||
@@ -0,0 +1,24 @@ | |||
1 | <div class="markdown"><ul> | ||
2 | <li>test: | ||
3 | <ul> | ||
4 | <li><a href="http://link.tld">zero</a></li> | ||
5 | <li><a href="http://link.tld">two</a></li> | ||
6 | <li><a href="http://link.tld">three</a></li> | ||
7 | </ul></li> | ||
8 | </ul> | ||
9 | <ol> | ||
10 | <li><a href="http://link.tld">zero</a> | ||
11 | <ol> | ||
12 | <li><a href="http://link.tld">two</a></li> | ||
13 | <li><a href="http://link.tld">three</a></li> | ||
14 | <li><a href="http://link.tld">four</a></li> | ||
15 | <li>foo <a href="?addtag=foobar" title="Hashtag foobar">#foobar</a></li> | ||
16 | </ol></li> | ||
17 | </ol> | ||
18 | <p><a href="?addtag=foobar" title="Hashtag foobar">#foobar</a> foo <code>lol #foo</code> <a href="?addtag=bar" title="Hashtag bar">#bar</a></p> | ||
19 | <p>fsdfs <a href="http://link.tld">http://link.tld</a> <a href="?addtag=foobar" title="Hashtag foobar">#foobar</a> <code>http://link.tld</code></p> | ||
20 | <pre><code>http://link.tld #foobar | ||
21 | next #foo</code></pre> | ||
22 | <p>Block:</p> | ||
23 | <pre><code>lorem ipsum #foobar http://link.tld | ||
24 | #foobar http://link.tld</code></pre></div> \ No newline at end of file | ||
diff --git a/tests/plugins/resources/markdown.md b/tests/plugins/resources/markdown.md new file mode 100644 index 00000000..0b8be7c5 --- /dev/null +++ b/tests/plugins/resources/markdown.md | |||
@@ -0,0 +1,24 @@ | |||
1 | * test: | ||
2 | * [zero](http://link.tld) | ||
3 | + [two](http://link.tld) | ||
4 | - [three](http://link.tld) | ||
5 | |||
6 | 1. [zero](http://link.tld) | ||
7 | 2. [two](http://link.tld) | ||
8 | 3. [three](http://link.tld) | ||
9 | 4. [four](http://link.tld) | ||
10 | 5. foo #foobar | ||
11 | |||
12 | #foobar foo `lol #foo` #bar | ||
13 | |||
14 | fsdfs http://link.tld #foobar `http://link.tld` | ||
15 | |||
16 | http://link.tld #foobar | ||
17 | next #foo | ||
18 | |||
19 | Block: | ||
20 | |||
21 | ``` | ||
22 | lorem ipsum #foobar http://link.tld | ||
23 | #foobar http://link.tld | ||
24 | ``` \ No newline at end of file | ||
diff --git a/tests/plugins/test/test.meta b/tests/plugins/test/test.meta index ab999ed4..26f243f0 100644 --- a/tests/plugins/test/test.meta +++ b/tests/plugins/test/test.meta | |||
@@ -1,2 +1,4 @@ | |||
1 | description="test plugin" | 1 | description="test plugin" |
2 | parameters="pop;hip" \ No newline at end of file | 2 | parameters="pop;hip" |
3 | parameter.pop="pop description" | ||
4 | parameter.hip= \ No newline at end of file | ||