aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/plugins/PluginMarkdownTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-11-17 21:01:11 +0100
committerArthurHoaro <arthur@hoa.ro>2016-01-03 17:36:10 +0100
commit1be4afacf98e0124258199ec416dc1c4b4948305 (patch)
tree8c0bdf7997d5a9a048a8fb7503417422caa9f4aa /tests/plugins/PluginMarkdownTest.php
parent79851b489087f8a3027ecd805255cd13ee6fcf63 (diff)
downloadShaarli-1be4afacf98e0124258199ec416dc1c4b4948305.tar.gz
Shaarli-1be4afacf98e0124258199ec416dc1c4b4948305.tar.zst
Shaarli-1be4afacf98e0124258199ec416dc1c4b4948305.zip
PLUGIN Markdown
Parse link description in Markdown (HTML) before rendering. * hard remove of Shaarli's HTML before parsing. * Using Parsedown <https://github.com/erusev/parsedown> PHP lib. * Includes basic markdown CSS. * Style: removed 400px height max limit for shaares. * Unit tests.
Diffstat (limited to 'tests/plugins/PluginMarkdownTest.php')
-rw-r--r--tests/plugins/PluginMarkdownTest.php112
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
new file mode 100644
index 00000000..455f5ba7
--- /dev/null
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -0,0 +1,112 @@
1<?php
2
3/**
4 * PluginMarkdownTest.php
5 */
6
7require_once 'application/Utils.php';
8require_once 'plugins/markdown/markdown.php';
9
10/**
11 * Class PlugQrcodeTest
12 * Unit test for the QR-Code plugin
13 */
14class PluginMarkdownTest 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_linklist hook.
26 * Only check that there is basic markdown rendering.
27 */
28 function testMarkdownLinklist()
29 {
30 $markdown = '# My title' . PHP_EOL . 'Very interesting content.';
31 $data = array(
32 'links' => array(
33 0 => array(
34 'description' => $markdown,
35 ),
36 ),
37 );
38
39 $data = hook_markdown_render_linklist($data);
40 $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>'));
41 $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>'));
42 }
43
44 /**
45 * Test render_daily hook.
46 * Only check that there is basic markdown rendering.
47 */
48 function testMarkdownDaily()
49 {
50 $markdown = '# My title' . PHP_EOL . 'Very interesting content.';
51 $data = array(
52 // Columns data
53 'cols' => array(
54 // First, second, third.
55 0 => array(
56 // nth link
57 0 => array(
58 'formatedDescription' => $markdown,
59 ),
60 ),
61 ),
62 );
63
64 $data = hook_markdown_render_daily($data);
65 $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<h1>'));
66 $this->assertNotFalse(strpos($data['cols'][0][0]['formatedDescription'], '<p>'));
67 }
68
69 /**
70 * Test reverse_text2clickable().
71 */
72 function testReverseText2clickable()
73 {
74 $text = 'stuff http://hello.there/is=someone#here otherstuff';
75 $clickableText = text2clickable($text, '');
76 $reversedText = reverse_text2clickable($clickableText);
77 $this->assertEquals($text, $reversedText);
78 }
79
80 /**
81 * Test reverse_nl2br().
82 */
83 function testReverseNl2br()
84 {
85 $text = 'stuff' . PHP_EOL . 'otherstuff';
86 $processedText = nl2br($text);
87 $reversedText = reverse_nl2br($processedText);
88 $this->assertEquals($text, $reversedText);
89 }
90
91 /**
92 * Test reverse_space2nbsp().
93 */
94 function testReverseSpace2nbsp()
95 {
96 $text = ' stuff' . PHP_EOL . ' otherstuff and another';
97 $processedText = space2nbsp($text);
98 $reversedText = reverse_space2nbsp($processedText);
99 $this->assertEquals($text, $reversedText);
100 }
101
102 /**
103 * Test reset_quote_tags()
104 */
105 function testResetQuoteTags()
106 {
107 $text = '> quote1'. PHP_EOL . ' > quote2 ' . PHP_EOL . 'noquote';
108 $processedText = escape($text);
109 $reversedText = reset_quote_tags($processedText);
110 $this->assertEquals($text, $reversedText);
111 }
112}