]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/LinkUtilsTest.php
Merge pull request #977 from ArthurHoaro/feature/dl-filter
[github/shaarli/Shaarli.git] / tests / LinkUtilsTest.php
index ef650f448d382fd2e4ab7ab7959186f831c255c9..7fbd59b0b80489d7b9e3521664e8aeb7d204b19d 100644 (file)
@@ -214,6 +214,16 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase
         $expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff';
         $processedText = text2clickable($text, '');
         $this->assertEquals($expectedText, $processedText);
+
+        $text = 'stuff http://hello.there/is=someone#here(please) otherstuff';
+        $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">http://hello.there/is=someone#here(please)</a> otherstuff';
+        $processedText = text2clickable($text, '');
+        $this->assertEquals($expectedText, $processedText);
+
+        $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
+        $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">http://hello.there/is=someone#here(please)&no</a> otherstuff';
+        $processedText = text2clickable($text, '');
+        $this->assertEquals($expectedText, $processedText);
     }
 
     /**
@@ -231,6 +241,21 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase
         $this->assertEquals($expectedText, $processedText);
     }
 
+    /**
+     * Test text2clickable a redirector set and without URL encode.
+     */
+    public function testText2clickableWithRedirectorDontEncode()
+    {
+        $text = 'stuff http://hello.there/?is=someone&or=something#here otherstuff';
+        $redirector = 'http://redirector.to';
+        $expectedText = 'stuff <a href="'.
+            $redirector .
+            'http://hello.there/?is=someone&or=something#here' .
+            '">http://hello.there/?is=someone&or=something#here</a> otherstuff';
+        $processedText = text2clickable($text, $redirector, false);
+        $this->assertEquals($expectedText, $processedText);
+    }
+
     /**
      * Test testSpace2nbsp.
      */