Annotation of embedaddon/php/ext/filter/tests/015.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: filter_var() and FILTER_VALIDATE_URL
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("filter")) die("skip"); ?>
! 5: --FILE--
! 6: <?php
! 7:
! 8: $values = Array(
! 9: 'http://example.com/index.html',
! 10: 'http://www.example.com/index.php',
! 11: 'http://www.example/img/test.png',
! 12: 'http://www.example/img/dir/',
! 13: 'http://www.example/img/dir',
! 14: 'http//www.example/wrong/url/',
! 15: 'http:/www.example',
! 16: 'file:///tmp/test.c',
! 17: 'ftp://ftp.example.com/tmp/',
! 18: '/tmp/test.c',
! 19: '/',
! 20: 'http://',
! 21: 'http:/',
! 22: 'http:',
! 23: 'http',
! 24: '',
! 25: -1,
! 26: array(),
! 27: 'mailto:foo@bar.com',
! 28: 'news:news.php.net',
! 29: 'file://foo/bar',
! 30: "http://\r\n/bar",
! 31: "http://example.com:qq",
! 32: "http://example.com:-2",
! 33: "http://example.com:65536",
! 34: "http://example.com:65537",
! 35: );
! 36: foreach ($values as $value) {
! 37: var_dump(filter_var($value, FILTER_VALIDATE_URL));
! 38: }
! 39:
! 40:
! 41: var_dump(filter_var("qwe", FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
! 42: var_dump(filter_var("http://qwe", FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED));
! 43: var_dump(filter_var("http://", FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED));
! 44: var_dump(filter_var("/tmp/test", FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED));
! 45: var_dump(filter_var("http://www.example.com", FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED));
! 46: var_dump(filter_var("http://www.example.com", FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));
! 47: var_dump(filter_var("http://www.example.com/path/at/the/server/", FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));
! 48: var_dump(filter_var("http://www.example.com/index.html", FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED));
! 49: var_dump(filter_var("http://www.example.com/index.php?a=b&c=d", FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED));
! 50:
! 51: echo "Done\n";
! 52: ?>
! 53: --EXPECT--
! 54: string(29) "http://example.com/index.html"
! 55: string(32) "http://www.example.com/index.php"
! 56: string(31) "http://www.example/img/test.png"
! 57: string(27) "http://www.example/img/dir/"
! 58: string(26) "http://www.example/img/dir"
! 59: bool(false)
! 60: bool(false)
! 61: string(18) "file:///tmp/test.c"
! 62: string(26) "ftp://ftp.example.com/tmp/"
! 63: bool(false)
! 64: bool(false)
! 65: bool(false)
! 66: bool(false)
! 67: bool(false)
! 68: bool(false)
! 69: bool(false)
! 70: bool(false)
! 71: bool(false)
! 72: string(18) "mailto:foo@bar.com"
! 73: string(17) "news:news.php.net"
! 74: string(14) "file://foo/bar"
! 75: bool(false)
! 76: bool(false)
! 77: bool(false)
! 78: bool(false)
! 79: bool(false)
! 80: bool(false)
! 81: string(10) "http://qwe"
! 82: bool(false)
! 83: bool(false)
! 84: string(22) "http://www.example.com"
! 85: bool(false)
! 86: string(42) "http://www.example.com/path/at/the/server/"
! 87: bool(false)
! 88: string(40) "http://www.example.com/index.php?a=b&c=d"
! 89: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>