From ced34cb15e095836767971aa4d27b141fb1d7ec9 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 18 Oct 2014 08:47:54 -0400
Subject: [PATCH] Merge pull request #230 from bytesatwork-xx/master

---
 tests/Framework/StringReplacer.php |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/tests/Framework/StringReplacer.php b/tests/Framework/StringReplacer.php
index 8f6eaf4..7d9600a 100644
--- a/tests/Framework/StringReplacer.php
+++ b/tests/Framework/StringReplacer.php
@@ -41,6 +41,11 @@
             array('http://', 'http://'),
             array('1@1.com www.domain.tld', '<a href="mailto:1@1.com">1@1.com</a> <a href="http://www.domain.tld">www.domain.tld</a>'),
             array(' www.domain.tld ', ' <a href="http://www.domain.tld">www.domain.tld</a> '),
+            array(' www.domain.tld/#!download|856p1|2 ', ' <a href="http://www.domain.tld/#!download|856p1|2">www.domain.tld/#!download|856p1|2</a> '),
+            // #1489898: allow some unicode characters
+            array('https://www.google.com/maps/place/New+York,+État+de+New+York/@40.7056308,-73.9780035,11z/data=!3m1!4b1!4m2!3m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62',
+                '<a href="https://www.google.com/maps/place/New+York,+État+de+New+York/@40.7056308,-73.9780035,11z/data=!3m1!4b1!4m2!3m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62">https://www.google.com/maps/place/New+York,+État+de+New+York/@40.7056308,-73.9780035,11z/data=!3m1!4b1!4m2!3m1!1s0x89c24fa5d33f083b:0xc80b8f06e177fe62</a>'
+            ),
         );
     }
 
@@ -55,4 +60,20 @@
 
         $this->assertEquals($output, $result);
     }
+
+    function test_linkrefs()
+    {
+        $input = "This is a sample message [1] to test the new linkref [ref0] replacement feature of [Roundcube].\n";
+        $input.= "\n";
+        $input.= "[1] http://en.wikipedia.org/wiki/Email\n";
+        $input.= "[ref0] www.link-ref.com\n";
+
+        $replacer = new rcube_string_replacer;
+        $result = $replacer->replace($input);
+        $result = $replacer->resolve($result);
+
+        $this->assertContains('[<a href="http://en.wikipedia.org/wiki/Email">1</a>] to', $result, "Numeric linkref replacements");
+        $this->assertContains('[<a href="http://www.link-ref.com">ref0</a>] repl', $result, "Alphanum linkref replacements");
+        $this->assertContains('of [Roundcube].', $result, "Don't touch strings wihtout an index entry");
+    }
 }

--
Gitblit v1.9.1