aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins')
-rw-r--r--tests/plugins/PluginIssoTest.php16
-rw-r--r--tests/plugins/PluginMarkdownTest.php14
-rw-r--r--tests/plugins/resources/hashtags.md10
-rw-r--r--tests/plugins/resources/hashtags.raw10
-rw-r--r--tests/plugins/resources/markdown.html8
-rw-r--r--tests/plugins/resources/markdown.md2
6 files changed, 48 insertions, 12 deletions
diff --git a/tests/plugins/PluginIssoTest.php b/tests/plugins/PluginIssoTest.php
index 0ae73183..2c9efbcd 100644
--- a/tests/plugins/PluginIssoTest.php
+++ b/tests/plugins/PluginIssoTest.php
@@ -21,7 +21,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
21 /** 21 /**
22 * Test Isso init without errors. 22 * Test Isso init without errors.
23 */ 23 */
24 public function testWallabagInitNoError() 24 public function testIssoInitNoError()
25 { 25 {
26 $conf = new ConfigManager(''); 26 $conf = new ConfigManager('');
27 $conf->set('plugins.ISSO_SERVER', 'value'); 27 $conf->set('plugins.ISSO_SERVER', 'value');
@@ -32,7 +32,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
32 /** 32 /**
33 * Test Isso init with errors. 33 * Test Isso init with errors.
34 */ 34 */
35 public function testWallabagInitError() 35 public function testIssoInitError()
36 { 36 {
37 $conf = new ConfigManager(''); 37 $conf = new ConfigManager('');
38 $errors = isso_init($conf); 38 $errors = isso_init($conf);
@@ -96,19 +96,22 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
96 array( 96 array(
97 'id' => 12, 97 'id' => 12,
98 'url' => $str, 98 'url' => $str,
99 'shorturl' => $short1 = 'abcd',
99 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date1), 100 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date1),
100 ), 101 ),
101 array( 102 array(
102 'id' => 13, 103 'id' => 13,
103 'url' => $str . '2', 104 'url' => $str . '2',
105 'shorturl' => $short2 = 'efgh',
104 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date2), 106 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date2),
105 ), 107 ),
106 ) 108 )
107 ); 109 );
108 110
109 $processed = hook_isso_render_linklist($data, $conf); 111 $processed = hook_isso_render_linklist($data, $conf);
110 // data shouldn't be altered 112 // link_plugin should be added for the icon
111 $this->assertEquals($data, $processed); 113 $this->assertContains('<a href="?'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]);
114 $this->assertContains('<a href="?'. $short2 .'#isso-thread">', $processed['links'][1]['link_plugin'][0]);
112 } 115 }
113 116
114 /** 117 /**
@@ -127,6 +130,7 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
127 array( 130 array(
128 'id' => 12, 131 'id' => 12,
129 'url' => $str, 132 'url' => $str,
133 'shorturl' => $short1 = 'abcd',
130 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date), 134 'created' => DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $date),
131 ) 135 )
132 ), 136 ),
@@ -135,8 +139,8 @@ class PluginIssoTest extends PHPUnit_Framework_TestCase
135 139
136 $processed = hook_isso_render_linklist($data, $conf); 140 $processed = hook_isso_render_linklist($data, $conf);
137 141
138 // data shouldn't be altered 142 // link_plugin should be added for the icon
139 $this->assertEquals($data, $processed); 143 $this->assertContains('<a href="?'. $short1 .'#isso-thread">', $processed['links'][0]['link_plugin'][0]);
140 } 144 }
141 145
142 /** 146 /**
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index b31e817f..319a94ba 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -107,6 +107,18 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
107 } 107 }
108 108
109 /** 109 /**
110 * Test reverse_text2clickable().
111 */
112 public function testReverseText2clickableHashtags()
113 {
114 $text = file_get_contents('tests/plugins/resources/hashtags.raw');
115 $md = file_get_contents('tests/plugins/resources/hashtags.md');
116 $clickableText = hashtag_autolink($text);
117 $reversedText = reverse_text2clickable($clickableText);
118 $this->assertEquals($md, $reversedText);
119 }
120
121 /**
110 * Test reverse_nl2br(). 122 * Test reverse_nl2br().
111 */ 123 */
112 public function testReverseNl2br() 124 public function testReverseNl2br()
@@ -246,7 +258,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
246 $this->conf->get('security.markdown_escape', true), 258 $this->conf->get('security.markdown_escape', true),
247 $this->conf->get('security.allowed_protocols') 259 $this->conf->get('security.allowed_protocols')
248 ); 260 );
249 $this->assertEquals($html, $data); 261 $this->assertEquals($html, $data . PHP_EOL);
250 } 262 }
251 263
252 /** 264 /**
diff --git a/tests/plugins/resources/hashtags.md b/tests/plugins/resources/hashtags.md
new file mode 100644
index 00000000..46326de3
--- /dev/null
+++ b/tests/plugins/resources/hashtags.md
@@ -0,0 +1,10 @@
1[#lol](?addtag=lol)
2
3 #test
4
5`#test2`
6
7```
8bla #bli blo
9#bla
10```
diff --git a/tests/plugins/resources/hashtags.raw b/tests/plugins/resources/hashtags.raw
new file mode 100644
index 00000000..9d2dc98a
--- /dev/null
+++ b/tests/plugins/resources/hashtags.raw
@@ -0,0 +1,10 @@
1#lol
2
3 #test
4
5`#test2`
6
7```
8bla #bli blo
9#bla
10```
diff --git a/tests/plugins/resources/markdown.html b/tests/plugins/resources/markdown.html
index f1df4e7e..c3460bf7 100644
--- a/tests/plugins/resources/markdown.html
+++ b/tests/plugins/resources/markdown.html
@@ -12,11 +12,11 @@
12<li><a href="http://link.tld">two</a></li> 12<li><a href="http://link.tld">two</a></li>
13<li><a href="http://link.tld">three</a></li> 13<li><a href="http://link.tld">three</a></li>
14<li><a href="http://link.tld">four</a></li> 14<li><a href="http://link.tld">four</a></li>
15<li>foo &lt;a href=&quot;?addtag=foobar&quot; title=&quot;Hashtag foobar&quot;&gt;#foobar&lt;/a&gt;</li> 15<li>foo <a href="?addtag=foobar">#foobar</a></li>
16</ol></li> 16</ol></li>
17</ol> 17</ol>
18<p>&lt;a href=&quot;?addtag=foobar&quot; title=&quot;Hashtag foobar&quot;&gt;#foobar&lt;/a&gt; foo <code>lol #foo</code> &lt;a href=&quot;?addtag=bar&quot; title=&quot;Hashtag bar&quot;&gt;#bar&lt;/a&gt;</p> 18<p><a href="?addtag=foobar">#foobar</a> foo <code>lol #foo</code> <a href="?addtag=bar">#bar</a></p>
19<p>fsdfs <a href="http://link.tld">http://link.tld</a> &lt;a href=&quot;?addtag=foobar&quot; title=&quot;Hashtag foobar&quot;&gt;#foobar&lt;/a&gt; <code>http://link.tld</code></p> 19<p>fsdfs <a href="http://link.tld">http://link.tld</a> <a href="?addtag=foobar">#foobar</a> <code>http://link.tld</code></p>
20<pre><code>http://link.tld #foobar 20<pre><code>http://link.tld #foobar
21next #foo</code></pre> 21next #foo</code></pre>
22<p>Block:</p> 22<p>Block:</p>
@@ -30,4 +30,4 @@ next #foo</code></pre>
30<a href="ftp://test.tld/path/?query=value#hash">link</a><br /> 30<a href="ftp://test.tld/path/?query=value#hash">link</a><br />
31<a href="magnet:test.tld/path/?query=value#hash">link</a><br /> 31<a href="magnet:test.tld/path/?query=value#hash">link</a><br />
32<a href="http://alert(&#039;xss&#039;)">link</a><br /> 32<a href="http://alert(&#039;xss&#039;)">link</a><br />
33<a href="http://test.tld/path/?query=value#hash">link</a></p></div> \ No newline at end of file 33<a href="http://test.tld/path/?query=value#hash">link</a></p></div>
diff --git a/tests/plugins/resources/markdown.md b/tests/plugins/resources/markdown.md
index b8ebd934..9350a8c7 100644
--- a/tests/plugins/resources/markdown.md
+++ b/tests/plugins/resources/markdown.md
@@ -31,4 +31,4 @@ lorem ipsum #foobar http://link.tld
31[link](ftp://test.tld/path/?query=value#hash) 31[link](ftp://test.tld/path/?query=value#hash)
32[link](magnet:test.tld/path/?query=value#hash) 32[link](magnet:test.tld/path/?query=value#hash)
33[link](javascript:alert('xss')) 33[link](javascript:alert('xss'))
34[link](other://test.tld/path/?query=value#hash) \ No newline at end of file 34[link](other://test.tld/path/?query=value#hash)