]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/plugins/PluginMarkdownTest.php
Fix an issue with links not being reversed in code blocks
[github/shaarli/Shaarli.git] / tests / plugins / PluginMarkdownTest.php
index 8e1a128acc6d2b00218611af2f7257fd0ff437a7..12bdda24231b47a9cad0454694d030d7b4884362 100644 (file)
@@ -102,7 +102,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
     /**
      * Test sanitize_html().
      */
-    function testSanitizeHtml() {
+    function testSanitizeHtml()
+    {
         $input = '< script src="js.js"/>';
         $input .= '< script attr>alert(\'xss\');</script>';
         $input .= '<style> * { display: none }</style>';
@@ -114,4 +115,53 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
         $input = escape($input);
         $this->assertEquals($input, sanitize_html($input));
     }
+
+    /**
+     * Test the no markdown tag.
+     */
+    function testNoMarkdownTag()
+    {
+        $str = 'All _work_ and `no play` makes Jack a *dull* boy.';
+        $data = array(
+            'links' => array(array(
+                'description' => $str,
+                'tags' => NO_MD_TAG,
+                'taglist' => array(NO_MD_TAG),
+            ))
+        );
+
+        $data = hook_markdown_render_linklist($data);
+        $this->assertEquals($str, $data['links'][0]['description']);
+
+        $data = array(
+            // Columns data
+            'cols' => array(
+                // First, second, third.
+                0 => array(
+                    // nth link
+                    0 => array(
+                        'formatedDescription' => $str,
+                        'tags' => NO_MD_TAG,
+                        'taglist' => array(),
+                    ),
+                ),
+            ),
+        );
+
+        $data = hook_markdown_render_daily($data);
+        $this->assertEquals($str, $data['cols'][0][0]['formatedDescription']);
+    }
+
+    /**
+     * Test hashtag links processed with markdown.
+     */
+    function testMarkdownHashtagLinks()
+    {
+        $md = file_get_contents('tests/plugins/resources/markdown.md');
+        $md = format_description($md);
+        $html = file_get_contents('tests/plugins/resources/markdown.html');
+
+        $data = process_markdown($md);
+        $this->assertEquals($html, $data);
+    }
 }