Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

weblib MDL-21168 added some more tests

  • Loading branch information...
commit bdac61091c6b217c431f94cd9521c3a59bad7571 1 parent 1f6a371
Andrew Davis authored

Showing 1 changed file with 14 additions and 5 deletions. Show diff stats Hide diff stats

  1. +14 5 lib/simpletest/testweblib.php
19 lib/simpletest/testweblib.php
@@ -135,7 +135,7 @@ function test_convert_urls_into_links() {
135 135 'URL: <a href="http://moodle.org">www.moodle.org</a>' => 'URL: <a href="http://moodle.org">www.moodle.org</a>',
136 136 'URL: <a href="http://moodle.org"> http://moodle.org</a>' => 'URL: <a href="http://moodle.org"> http://moodle.org</a>',
137 137 'URL: <a href="http://moodle.org"> www.moodle.org</a>' => 'URL: <a href="http://moodle.org"> www.moodle.org</a>',
138   - //escaped anchor tag
  138 + //escaped anchor tag. todo decide whether we want to make this work. MDL-21183
139 139 htmlspecialchars('escaped anchor tag <a href="http://moodle.org">www.moodle.org</a>') => 'escaped anchor tag &lt;a href="http://moodle.org"&gt; www.moodle.org&lt;/a&gt;',
140 140 //trailing fullstop
141 141 'URL: http://moodle.org/s/i=1&j=2.' => 'URL: <a href="http://moodle.org/s/i=1&j=2" target="_blank">http://moodle.org/s/i=1&j=2</a>.',
@@ -164,9 +164,10 @@ function test_convert_urls_into_links() {
164 164 'This contains http, http:// and www but no actual links.'=>'This contains http, http:// and www but no actual links.',
165 165 //no link at all
166 166 'This is a story about moodle.coming to a cinema near you.'=>'This is a story about moodle.coming to a cinema near you.',
167   - //utf 8 characters
  167 + //URLs containing utf 8 characters
168 168 'http://Iñtërnâtiônàlizætiøn.com?ô=nëø'=>'<a href="http://Iñtërnâtiônàlizætiøn.com?ô=nëø" target="_blank">http://Iñtërnâtiônàlizætiøn.com?ô=nëø</a>',
169   - 'www.Iñtërnâtiônàlizætiøn.com?ô=nëø'=>'<a href="http://www.Iñtërnâtiônàlizætiøn.com?ô=nëø" target="_blank">www.Iñtërnâtiônàlizætiøn.com?ô=nëø</a>',
  169 + //text containing utf 8 characters outside of a url
  170 + '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 <a href="http://moodle.org" target="_blank">http://moodle.org</a>',
170 171 //too hard to identify without additional regexs
171 172 'moodle.org' => 'moodle.org',
172 173 //some text with no link between related html tags
@@ -181,12 +182,20 @@ function test_convert_urls_into_links() {
181 182 //and another url within one tag
182 183 '<td background="http://moodle.org">&nbsp;</td>' => '<td background="http://moodle.org">&nbsp;</td>',
183 184 '<td background="www.moodle.org">&nbsp;</td>' => '<td background="www.moodle.org">&nbsp;</td>',
  185 + '<form name="input" action="http://moodle.org/submit.asp" method="get">'=>'<form name="input" action="http://moodle.org/submit.asp" method="get">',
184 186 //partially escaped img tag
185 187 'partially escaped img tag &lt;img src="http://moodle.org/logo/logo-240x60.gif" />' => 'partially escaped img tag &lt;img src="http://moodle.org/logo/logo-240x60.gif" />',
186   - //fully escaped img tag
  188 + //fully escaped img tag. Do we want this to work on escaped text? MDL-21183
187 189 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;',
188 190 //Double http with www
189   - 'One more link like http://www.moodle.org to test' => 'One more link like <a href="http://www.moodle.org" target="_blank">http://www.moodle.org</a> to test'
  191 + 'One more link like http://www.moodle.org to test' => 'One more link like <a href="http://www.moodle.org" target="_blank">http://www.moodle.org</a> to test',
  192 + //URLs in Javascript
  193 + 'var url="http://moodle.org";'=>'var url="http://moodle.org";',
  194 + 'var url = "http://moodle.org";'=>'var url = "http://moodle.org";',
  195 + 'var url="www.moodle.org";'=>'var url="www.moodle.org";',
  196 + 'var url = "www.moodle.org";'=>'var url = "www.moodle.org";',
  197 + //doctype. do we care about this failing?
  198 + //'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd">'=>'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd">'
190 199 );
191 200 foreach ($texts as $text => $correctresult) {
192 201 $msg = "Testing text: ". str_replace('%', '%%', $text) . ": %s"; // Escape original '%' so sprintf() wont get confused

0 comments on commit bdac610

Please sign in to comment.
Something went wrong with that request. Please try again.