',
//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. Commented out as part of 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',
//Encoded URLs in the path
'URL: http://127.0.0.1/one%28parenthesis%29/path?param=value' => 'URL: http://127.0.0.1/one%28parenthesis%29/path?param=value',
'URL: www.localhost.com/one%28parenthesis%29/path?param=value' => 'URL: www.localhost.com/one%28parenthesis%29/path?param=value',
//Encoded URLs in the query
'URL: http://127.0.0.1/path/to?param=value_with%28parenthesis%29¶m2=1' => 'URL: http://127.0.0.1/path/to?param=value_with%28parenthesis%29¶m2=1',
'URL: www.localhost.com/path/to?param=value_with%28parenthesis%29¶m2=1' => 'URL: www.localhost.com/path/to?param=value_with%28parenthesis%29¶m2=1',
// Test URL less than 4096 characters in size is converted to link.
'URL: ' . $superlong4095 => 'URL: ' . $superlong4095 . '',
// Test URL equal to or greater than 4096 characters in size is not converted to link.
'URL: ' . $superlong4096 => 'URL: ' . $superlong4096,
// Testing URL within a span tag.
'URL: my link to http://google.com ' => 'URL: my link to http://google.com ',
// Nested tags test.
'www.google.com' => 'www.google.com',
'' => '',
// Test realistic content.
'Lorem ipsum amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut http://google.com aliquip ex ea commodo consequat. Duis aute irure in reprehenderit in excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing mollit anim id est laborum.
'
=>
'Lorem ipsum amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut http://google.com aliquip ex ea commodo consequat. Duis aute irure in reprehenderit in excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing https://docs.google.com/document/d/BrokenLinkPleaseAyacDHc_Ov8aoskoSVQsfmLHP_jYAkRMk/edit?usp=sharing mollit anim id est laborum.
',
// Test some broken html.
'5 < 10 www.google.com im a link' => '5 < 10 www.google.com im a link',
'h3 (www.styles.com/h3) < h1 (www.styles.com/h1)' => 'h3 (www.styles.com/h3) < h1 (www.styles.com/h1)',
'text www.moodle.org</p> text' => '
text www.moodle.org</p> text',
// Some more urls.
'' => '',
'www.google.com' => 'www.google.com',
'http://nolandforzombies.com Zombies FTW http://aliens.org' => 'http://nolandforzombies.com Zombies FTW http://aliens.org',
// Test 'nolink' class.
'URL: http://moodle.org' => 'URL: http://moodle.org',
'URL: http://moodle.org' => 'URL: http://moodle.org',
//URLs in Javascript. Commented out as part of MDL-21183
//'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?
//''=>''
);
$data = array();
foreach ($texts as $text => $correctresult) {
$data[] = array($text, $correctresult);
}
return $data;
}
/**
* @dataProvider get_convert_urls_into_links_test_cases
*/
function test_convert_urls_into_links($text, $correctresult) {
$testablefilter = new testable_filter_urltolink();
$testablefilter->convert_urls_into_links($text);
$this->assertEquals($correctresult, $text);
}
}
/**
* Test subclass that makes all the protected methods we want to test public.
*/
class testable_filter_urltolink extends filter_urltolink {
public function __construct() {
}
public function convert_urls_into_links(&$text) {
parent::convert_urls_into_links($text);
}
}