aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/PluginMarkdownTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/plugins/PluginMarkdownTest.php')
-rw-r--r--tests/plugins/PluginMarkdownTest.php83
1 files changed, 66 insertions, 17 deletions
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index 96891f1f..b31e817f 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -50,6 +50,30 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
50 } 50 }
51 51
52 /** 52 /**
53 * Test render_feed hook.
54 */
55 public function testMarkdownFeed()
56 {
57 $markdown = '# My title' . PHP_EOL . 'Very interesting content.';
58 $markdown .= '&#8212; <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>';
59 $data = array(
60 'links' => array(
61 0 => array(
62 'description' => $markdown,
63 ),
64 ),
65 );
66
67 $data = hook_markdown_render_feed($data, $this->conf);
68 $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>'));
69 $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>'));
70 $this->assertStringEndsWith(
71 '&#8212; <a href="http://domain.tld/?0oc_VQ">Permalien</a></p></div>',
72 $data['links'][0]['description']
73 );
74 }
75
76 /**
53 * Test render_daily hook. 77 * Test render_daily hook.
54 * Only check that there is basic markdown rendering. 78 * Only check that there is basic markdown rendering.
55 */ 79 */
@@ -58,20 +82,17 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
58 $markdown = '# My title' . PHP_EOL . 'Very interesting content.'; 82 $markdown = '# My title' . PHP_EOL . 'Very interesting content.';
59 $data = array( 83 $data = array(
60 // Columns data 84 // Columns data
61 'cols' => array( 85 'linksToDisplay' => array(
62 // First, second, third. 86 // nth link
63 0 => array( 87 0 => array(
64 // nth link 88 'formatedDescription' => $markdown,
65 0 => array(
66 'formatedDescription' => $markdown,
67 ),
68 ), 89 ),
69 ), 90 ),
70 ); 91 );
71 92
72 $data = hook_markdown_render_daily($data, $this->conf); 93 $data = hook_markdown_render_daily($data, $this->conf);
73 $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<h1>')); 94 $this->assertNotFalse(strpos($data['linksToDisplay'][0]['formatedDescription'], '<h1>'));
74 $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<p>')); 95 $this->assertNotFalse(strpos($data['linksToDisplay'][0]['formatedDescription'], '<p>'));
75 } 96 }
76 97
77 /** 98 /**
@@ -107,6 +128,37 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
107 $this->assertEquals($text, $reversedText); 128 $this->assertEquals($text, $reversedText);
108 } 129 }
109 130
131 public function testReverseFeedPermalink()
132 {
133 $text = 'Description... ';
134 $text .= '&#8212; <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>';
135 $expected = 'Description... &#8212; [Permalien](http://domain.tld/?0oc_VQ)';
136 $processedText = reverse_feed_permalink($text);
137
138 $this->assertEquals($expected, $processedText);
139 }
140
141 public function testReverseLastFeedPermalink()
142 {
143 $text = 'Description... ';
144 $text .= '<br>&#8212; <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>';
145 $expected = $text;
146 $text .= '<br>&#8212; <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>';
147 $expected .= '<br>&#8212; [Permalien](http://domain.tld/?0oc_VQ)';
148 $processedText = reverse_feed_permalink($text);
149
150 $this->assertEquals($expected, $processedText);
151 }
152
153 public function testReverseNoFeedPermalink()
154 {
155 $text = 'Hello! Where are you from?';
156 $expected = $text;
157 $processedText = reverse_feed_permalink($text);
158
159 $this->assertEquals($expected, $processedText);
160 }
161
110 /** 162 /**
111 * Test sanitize_html(). 163 * Test sanitize_html().
112 */ 164 */
@@ -148,21 +200,18 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
148 200
149 $data = array( 201 $data = array(
150 // Columns data 202 // Columns data
151 'cols' => array( 203 'linksToDisplay' => array(
152 // First, second, third. 204 // nth link
153 0 => array( 205 0 => array(
154 // nth link 206 'formatedDescription' => $str,
155 0 => array( 207 'tags' => NO_MD_TAG,
156 'formatedDescription' => $str, 208 'taglist' => array(),
157 'tags' => NO_MD_TAG,
158 'taglist' => array(),
159 ),
160 ), 209 ),
161 ), 210 ),
162 ); 211 );
163 212
164 $data = hook_markdown_render_daily($data, $this->conf); 213 $data = hook_markdown_render_daily($data, $this->conf);
165 $this->assertEquals($str, $data['cols'][0][0]['formatedDescription']); 214 $this->assertEquals($str, $data['linksToDisplay'][0]['formatedDescription']);
166 } 215 }
167 216
168 /** 217 /**