Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-41672 Add html2text unit test for multiple occurrences of the sam…

…e URL
  • Loading branch information...
commit 3bd02768dfc6fe90e5e9f886dc73da84f9dbf0dc 1 parent 9844660
David Mudrák mudrd8mz authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/tests/html2text_test.php
14 lib/tests/html2text_test.php
View
@@ -96,6 +96,20 @@ public function test_build_link_list() {
$this->assertSame(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 = '<p>See <a href="http://moodle.org">moodle.org</a>,
+ <a href="http://www.google.fr">google</a>, <a href="http://www.univ-lemans.fr">univ-lemans</a>
+ and <a href="http://www.google.fr">google</a>.
+ Also try <a href="https://www.google.fr">google via HTTPS</a>.';
+ $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 =======
Please sign in to comment.
Something went wrong with that request. Please try again.