Exemple #1
0
 function testIsURL()
 {
     $validURLs = array('http://www.nospammonkeys.org', 'http://www.eggheads.org/~wcc/test.txt', 'ftp://ftp.eggheads.org/wcc/test.txt', 'http://*****:*****@www.nospammonkeys.org', 'http://test@www.nospammonkeys.org', 'http://www.eggheads.org:80/~wcc/test.txt', 'http://*****:*****@www.nospammonkeys.org:80/q.php?test=1&test2=bl+ah', 'http://*****:*****@www.nospammonkeys.org:80/q.php?test=1&test2=/blah@blah.com', 'www.cognizo.com/index.php', 'http://24.72.64.156/index.php', 'localhost/index.php');
     $invalidURLs = array('770-667-5085', 'nntp://129.222.2532.5/index.php', '/index.php', 'My web site is http://www.microsoft.com/index.php and this is a test sentence.');
     foreach ($validURLs as $key => $value) {
         $this->assertTrue(StringUtility::isURL($value), sprintf("'%s' should be recognized as a URL", $value));
     }
     foreach ($invalidURLs as $key => $value) {
         $this->assertFalse(StringUtility::isURL($value), sprintf("'%s' should not be recognized as a URL", $value));
     }
 }