From: Andrew Davis Date: Mon, 11 Jan 2010 06:26:59 +0000 (+0000) Subject: weblib MDL-21168 Added some more unit tests X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=330cc667b0c1298e9cd6d87de6528c72184df3db;p=moodle.git weblib MDL-21168 Added some more unit tests --- diff --git a/lib/simpletest/testweblib.php b/lib/simpletest/testweblib.php index 1b144baa14..7ff45b6d0b 100644 --- a/lib/simpletest/testweblib.php +++ b/lib/simpletest/testweblib.php @@ -202,7 +202,7 @@ END; 'URL: www.moodle.org' => 'URL: www.moodle.org', 'URL: http://moodle.org' => 'URL: http://moodle.org', 'URL: www.moodle.org' => 'URL: www.moodle.org', - //escaped anchor tag + //escaped anchor tag. todo decide whether we want to make this work. MDL-21183 htmlspecialchars('escaped anchor tag www.moodle.org') => 'escaped anchor tag <a href="http://moodle.org"> www.moodle.org</a>', //trailing fullstop 'URL: http://moodle.org/s/i=1&j=2.' => 'URL: http://moodle.org/s/i=1&j=2.', @@ -231,9 +231,11 @@ END; 'This contains http, http:// and www but no actual links.'=>'This contains http, http:// and www but no actual links.', //no link at all 'This is a story about moodle.coming to a cinema near you.'=>'This is a story about moodle.coming to a cinema near you.', - //utf 8 characters + //URLs containing utf 8 characters 'http://Iñtërnâtiônàlizætiøn.com?ô=nëø'=>'http://Iñtërnâtiônàlizætiøn.com?ô=nëø', 'www.Iñtërnâtiônàlizætiøn.com?ô=nëø'=>'www.Iñtërnâtiônàlizætiøn.com?ô=nëø', + //text containing utf 8 characters outside of a url ++ 'Iñtërnâtiônàlizætiøn is important to http://moodle.org'=>'Iñtërnâtiônàlizætiøn is important to http://moodle.org', //too hard to identify without additional regexs 'moodle.org' => 'moodle.org', //some text with no link between related html tags @@ -248,12 +250,20 @@ END; //and another url within one tag ' ' => ' ', ' ' => ' ', + '
'=>'', //partially escaped img tag 'partially escaped img tag <img src="http://moodle.org/logo/logo-240x60.gif" />' => 'partially escaped img tag <img src="http://moodle.org/logo/logo-240x60.gif" />', - //fully escaped img tag + //fully escaped img tag. Do we want this to work on escaped text? MDL-21183 htmlspecialchars('fully escaped img tag ') => 'fully escaped img tag <img src="http://moodle.org/logo/logo-240x60.gif" />', //Double http with www - 'One more link like http://www.moodle.org to test' => 'One more link like http://www.moodle.org to test' + 'One more link like http://www.moodle.org to test' => 'One more link like http://www.moodle.org to test', ++ //URLs in Javascript + 'var url="http://moodle.org";'=>'var url="http://moodle.org";', + 'var url = "http://moodle.org";'=>'var url = "http://moodle.org";', + 'var url="www.moodle.org";'=>'var url="www.moodle.org";', + 'var url = "www.moodle.org";'=>'var url = "www.moodle.org";', + //doctype. do we care about this failing? + //''=>'' ); foreach ($texts as $text => $correctresult) { $msg = "Testing text: ". str_replace('%', '%%', $text) . ": %s"; // Escape original '%' so sprintf() wont get confused