]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/plugins/PluginMarkdownTest.php
Apply the new system (Bookmark + Service) to the whole code base
[github/shaarli/Shaarli.git] / tests / plugins / PluginMarkdownTest.php
index 319a94ba835ccfaeadfc917e487d35cb7a584165..15fa9ba598672d27f46ec989c7c4fd63ccf1c8a7 100644 (file)
@@ -1,10 +1,14 @@
 <?php
+namespace Shaarli\Plugin\Markdown;
+
 use Shaarli\Config\ConfigManager;
+use Shaarli\Plugin\PluginManager;
 
 /**
  * PluginMarkdownTest.php
  */
 
+require_once 'application/bookmark/LinkUtils.php';
 require_once 'application/Utils.php';
 require_once 'plugins/markdown/markdown.php';
 
@@ -12,7 +16,7 @@ require_once 'plugins/markdown/markdown.php';
  * Class PluginMarkdownTest
  * Unit test for the Markdown plugin
  */
-class PluginMarkdownTest extends PHPUnit_Framework_TestCase
+class PluginMarkdownTest extends \PHPUnit\Framework\TestCase
 {
     /**
      * @var ConfigManager instance.
@@ -47,6 +51,8 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
         $data = hook_markdown_render_linklist($data, $this->conf);
         $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>'));
         $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>'));
+
+        $this->assertEquals($markdown, $data['links'][0]['description_src']);
     }
 
     /**
@@ -101,7 +107,7 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
     public function testReverseText2clickable()
     {
         $text = 'stuff http://hello.there/is=someone#here otherstuff';
-        $clickableText = text2clickable($text, '');
+        $clickableText = text2clickable($text);
         $reversedText = reverse_text2clickable($clickableText);
         $this->assertEquals($text, $reversedText);
     }
@@ -150,6 +156,16 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($expected, $processedText);
     }
 
+    public function testReverseFeedDirectLink()
+    {
+        $text = 'Description... ';
+        $text .= '&#8212; <a href="http://domain.tld/?0oc_VQ" title="Direct link">Direct link</a>';
+        $expected = 'Description... &#8212; [Direct link](http://domain.tld/?0oc_VQ)';
+        $processedText = reverse_feed_permalink($text);
+
+        $this->assertEquals($expected, $processedText);
+    }
+
     public function testReverseLastFeedPermalink()
     {
         $text = 'Description... ';