Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-21168 convert_urls_into_links() - minor changes to tests (code fo…

…rmatting,

utf_decode() out and properly escape % chars.
  • Loading branch information...
commit 7fd2dcec3cb064008aa0a6074588314d2ae1b180 1 parent ac13e67
@stronk7 stronk7 authored
Showing with 3 additions and 19 deletions.
  1. +3 −19 lib/simpletest/testweblib.php
View
22 lib/simpletest/testweblib.php
@@ -183,24 +183,10 @@ function test_convert_urls_into_links() {
htmlspecialchars('fully escaped img tag <img src="http://moodle.org/logo/logo-240x60.gif" />') => 'fully escaped img tag &lt;img src="http://moodle.org/logo/logo-240x60.gif" /&gt;',
);
foreach ($texts as $text => $correctresult) {
- if(mb_detect_encoding($text)=='UTF-8') {
- $text_for_msg = utf8_decode($text);
- }
- else {
- $text_for_msg = $text;
- }
- //urldecode text or things like %28 cause sprintf's, looking for %s's, to throw an exception
- $msg = "Testing text: ".urldecode($text_for_msg).": %s";
+ $msg = "Testing text: ". str_replace('%', '%%', $text) . ": %s"; // Escape original '%' so sprintf() wont get confused
convert_urls_into_links($text);
- //these decode's make all the strings non-garbled. The tests pass without them.
- if(mb_detect_encoding($text)=='UTF-8') {
- $text = utf8_decode($text);
- }
- if(mb_detect_encoding($correctresult)=='UTF-8') {
- $correctresult = utf8_decode($correctresult);
- }
$this->assertEqual($text, $correctresult, $msg);
}
@@ -208,8 +194,7 @@ function test_convert_urls_into_links() {
$reps = 1000;
$time_start = microtime(true);
- for($i=0;$i<$reps;$i++)
- {
+ for($i=0;$i<$reps;$i++) {
$text = $this->get_test_text();
convert_urls_into_links($text);
}
@@ -217,8 +202,7 @@ function test_convert_urls_into_links() {
$new_time = $time_end - $time_start;
$time_start = microtime(true);
- for($i=0;$i<$reps;$i++)
- {
+ for($i=0;$i<$reps;$i++) {
$text = $this->get_test_text();
$this->old_convert_urls_into_links($text);
}
Please sign in to comment.
Something went wrong with that request. Please try again.