From 1ee66b79a9d278caebfa574a1a349625e9a79e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Wed, 9 Oct 2013 15:38:21 +0200 Subject: [PATCH] MDL-41672 Add html2text unit test for multiple occurrences of the same URL --- lib/tests/html2text_test.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/tests/html2text_test.php b/lib/tests/html2text_test.php index 2791dd08790..acaac9f3691 100644 --- a/lib/tests/html2text_test.php +++ b/lib/tests/html2text_test.php @@ -96,6 +96,20 @@ have been fixed last weekassertSame(1, preg_match('|^'.preg_quote('[2] http://another.url/?f=a&b=2').'$|m', $result)); $this->assertSame(1, preg_match('|^'.preg_quote('[3] http://third.url/view.php').'$|m', $result)); $this->assertSame(false, strpos($result, '[4]')); + + // Test multiple occurrences of the same URL. + $text = '

See moodle.org, + google, univ-lemans + and google. + Also try google via HTTPS.'; + $result = html_to_text($text, 5000, true); + $this->assertSame(0, strpos($result, 'See moodle.org [1], google [2], univ-lemans [3] and google [2]. Also try google via HTTPS [4].')); + $this->assertSame(false, strpos($result, '[0]')); + $this->assertSame(1, preg_match('|^'.preg_quote('[1] http://moodle.org').'$|m', $result)); + $this->assertSame(1, preg_match('|^'.preg_quote('[2] http://www.google.fr').'$|m', $result)); + $this->assertSame(1, preg_match('|^'.preg_quote('[3] http://www.univ-lemans.fr').'$|m', $result)); + $this->assertSame(1, preg_match('|^'.preg_quote('[4] https://www.google.fr').'$|m', $result)); + $this->assertSame(false, strpos($result, '[5]')); } // ======= Standard html2text conversion features =======