diff options
author | ArthurHoaro <arthur@hoa.ro> | 2018-05-19 12:55:43 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2018-05-19 12:55:43 +0200 |
commit | dd6794cff8a1f26c4d08544d89e1df1f521dcb26 (patch) | |
tree | c0bb89271fa80c048bb060b8bb8a9310ad55bb90 /tests | |
parent | 73da3a269bd3a636b4764f858e42dcc096e5e0a5 (diff) | |
download | Shaarli-dd6794cff8a1f26c4d08544d89e1df1f521dcb26.tar.gz Shaarli-dd6794cff8a1f26c4d08544d89e1df1f521dcb26.tar.zst Shaarli-dd6794cff8a1f26c4d08544d89e1df1f521dcb26.zip |
Fix feed permalink rendering with markdown escape set to true
Fixes #1134
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/PluginMarkdownTest.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php index ddc2728d..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 .= '— <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 | '— <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 | */ |
@@ -104,6 +128,37 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase | |||
104 | $this->assertEquals($text, $reversedText); | 128 | $this->assertEquals($text, $reversedText); |
105 | } | 129 | } |
106 | 130 | ||
131 | public function testReverseFeedPermalink() | ||
132 | { | ||
133 | $text = 'Description... '; | ||
134 | $text .= '— <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>'; | ||
135 | $expected = 'Description... — [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>— <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>'; | ||
145 | $expected = $text; | ||
146 | $text .= '<br>— <a href="http://domain.tld/?0oc_VQ" title="Permalien">Permalien</a>'; | ||
147 | $expected .= '<br>— [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 | |||
107 | /** | 162 | /** |
108 | * Test sanitize_html(). | 163 | * Test sanitize_html(). |
109 | */ | 164 | */ |