diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/url | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/url')
43 files changed, 4825 insertions, 0 deletions
diff --git a/ext/standard/tests/url/base64_decode_basic_001.phpt b/ext/standard/tests/url/base64_decode_basic_001.phpt new file mode 100644 index 0000000..7aba807 --- /dev/null +++ b/ext/standard/tests/url/base64_decode_basic_001.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test base64_decode() function : basic functionality - ensure all base64 alphabet is supported. +--FILE-- +<?php +/* Prototype : proto string base64_decode(string str[, bool strict]) + * Description: Decodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +echo "Decode an input string containing the whole base64 alphabet:\n"; +$allbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; +var_dump(bin2hex(base64_decode($allbase64))); +var_dump(bin2hex(base64_decode($allbase64, false))); +var_dump(bin2hex(base64_decode($allbase64, true))); + +echo "Done"; +?> +--EXPECTF-- +Decode an input string containing the whole base64 alphabet: +string(96) "00108310518720928b30d38f41149351559761969b71d79f8218a39259a7a29aabb2dbafc31cb3d35db7e39ebbf3dfbf" +string(96) "00108310518720928b30d38f41149351559761969b71d79f8218a39259a7a29aabb2dbafc31cb3d35db7e39ebbf3dfbf" +string(96) "00108310518720928b30d38f41149351559761969b71d79f8218a39259a7a29aabb2dbafc31cb3d35db7e39ebbf3dfbf" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/base64_decode_basic_002.phpt b/ext/standard/tests/url/base64_decode_basic_002.phpt new file mode 100644 index 0000000..1289894 --- /dev/null +++ b/ext/standard/tests/url/base64_decode_basic_002.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test base64_decode() function : basic functionality - strict vs non-strict with non-base64 chars. +--FILE-- +<?php +/* Prototype : proto string base64_decode(string str[, bool strict]) + * Description: Decodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +echo "Decode 'hello world!':\n"; +$noWhiteSpace = "aGVsbG8gd29ybGQh"; +var_dump(base64_decode($noWhiteSpace)); +var_dump(base64_decode($noWhiteSpace, false)); +var_dump(base64_decode($noWhiteSpace, true)); + +echo "\nWhitespace does not affect base64_decode, even with \$strict===true:\n"; +$withWhiteSpace = "a GVs bG8gd2 + 9ybGQh"; +var_dump(base64_decode($withWhiteSpace)); +var_dump(base64_decode($withWhiteSpace, false)); +var_dump(base64_decode($withWhiteSpace, true)); + +echo "\nOther chars outside the base64 alphabet are ignored when \$strict===false, but cause failure with \$strict===true:\n"; +$badChars = $noWhiteSpace . '*'; +var_dump(base64_decode($badChars)); +var_dump(base64_decode($badChars, false)); +var_dump(base64_decode($badChars, true)); + +echo "Done"; +?> +--EXPECTF-- +Decode 'hello world!': +string(12) "hello world!" +string(12) "hello world!" +string(12) "hello world!" + +Whitespace does not affect base64_decode, even with $strict===true: +string(12) "hello world!" +string(12) "hello world!" +string(12) "hello world!" + +Other chars outside the base64 alphabet are ignored when $strict===false, but cause failure with $strict===true: +string(12) "hello world!" +string(12) "hello world!" +bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/base64_decode_error_001.phpt b/ext/standard/tests/url/base64_decode_error_001.phpt new file mode 100644 index 0000000..2725164 --- /dev/null +++ b/ext/standard/tests/url/base64_decode_error_001.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test base64_decode() function : error conditions - wrong number of args +--FILE-- +<?php +/* Prototype : proto string base64_decode(string str[, bool strict]) + * Description: Decodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +echo "*** Testing base64_decode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing base64_decode() function with Zero arguments --\n"; +var_dump( base64_decode() ); + +//Test base64_decode with one more than the expected number of arguments +echo "\n-- Testing base64_decode() function with more than expected no. of arguments --\n"; +$str = 'string_val'; +$strict = true; +$extra_arg = 10; +var_dump( base64_decode($str, $strict, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing base64_decode() : error conditions *** + +-- Testing base64_decode() function with Zero arguments -- + +Warning: base64_decode() expects at least 1 parameter, 0 given in %s on line 12 +NULL + +-- Testing base64_decode() function with more than expected no. of arguments -- + +Warning: base64_decode() expects at most 2 parameters, 3 given in %s on line 19 +NULL +Done diff --git a/ext/standard/tests/url/base64_decode_variation_001.phpt b/ext/standard/tests/url/base64_decode_variation_001.phpt new file mode 100644 index 0000000..8734a96 --- /dev/null +++ b/ext/standard/tests/url/base64_decode_variation_001.phpt @@ -0,0 +1,181 @@ +--TEST-- +Test base64_decode() function : usage variations - unexpected types for arg 1 +--FILE-- +<?php +/* Prototype : proto string base64_decode(string str[, bool strict]) + * Description: Decodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing base64_decode() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$strict = true; + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array ( + // int data + "0" => 0, + "1" => 1, + "12345" => 12345, + "-2345" => -2345, + + // float data + "10.5" => 10.5, + "-10.5" => -10.5, + "10.1234567e10" => 10.1234567e10, + "10.7654321E-10" => 10.7654321E-10, + ".5" => .5, + + // array data + "array()" => array(), + "array(0)" => array(0), + "array(1)" => array(1), + "array(1, 2)" => array(1, 2), + "array('color' => 'red', 'item' => 'pen'" => array('color' => 'red', 'item' => 'pen'), + + // null data + "NULL" => NULL, + "null" => null, + + // boolean data + "true" => true, + "false" => false, + "TRUE" => TRUE, + "FALSE" => FALSE, + + // empty data + "\"\"" => "", + "''" => '', + + // object data + "stdClass object" => new stdclass(), + + // undefined data + "undefined variable" => $undefined_var, + + // unset data + "unset variable" => $unset_var, + + // resource data + "resource" => $file_handle +); + +// loop through each element of the array for str argument + +foreach($values as $key=>$value) { + echo "\n-- Arg value $key --\n"; + $output = base64_decode($value, $strict); + + if (is_string($output)) { + var_dump(bin2hex($output)); + } else { + var_dump($output); + } +}; + +?> +===Done=== +--EXPECTF-- +*** Testing base64_decode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(%d) +Error: 8 - Undefined variable: unset_var, %s(%d) + +-- Arg value 0 -- +string(0) "" + +-- Arg value 1 -- +string(0) "" + +-- Arg value 12345 -- +string(6) "d76df8" + +-- Arg value -2345 -- +bool(false) + +-- Arg value 10.5 -- +bool(false) + +-- Arg value -10.5 -- +bool(false) + +-- Arg value 10.1234567e10 -- +string(18) "d74d76df8e7aef4d34" + +-- Arg value 10.7654321E-10 -- +bool(false) + +-- Arg value .5 -- +bool(false) + +-- Arg value array() -- +Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(%d) +NULL + +-- Arg value array(0) -- +Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(%d) +NULL + +-- Arg value array(1) -- +Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(%d) +NULL + +-- Arg value array(1, 2) -- +Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(%d) +NULL + +-- Arg value array('color' => 'red', 'item' => 'pen' -- +Error: 2 - base64_decode() expects parameter 1 to be string, array given, %s(%d) +NULL + +-- Arg value NULL -- +string(0) "" + +-- Arg value null -- +string(0) "" + +-- Arg value true -- +string(0) "" + +-- Arg value false -- +string(0) "" + +-- Arg value TRUE -- +string(0) "" + +-- Arg value FALSE -- +string(0) "" + +-- Arg value "" -- +string(0) "" + +-- Arg value '' -- +string(0) "" + +-- Arg value stdClass object -- +Error: 2 - base64_decode() expects parameter 1 to be string, object given, %s(%d) +NULL + +-- Arg value undefined variable -- +string(0) "" + +-- Arg value unset variable -- +string(0) "" + +-- Arg value resource -- +Error: 2 - base64_decode() expects parameter 1 to be string, resource given, %s(%d) +NULL +===Done===
\ No newline at end of file diff --git a/ext/standard/tests/url/base64_decode_variation_002.phpt b/ext/standard/tests/url/base64_decode_variation_002.phpt new file mode 100644 index 0000000..20bf357 --- /dev/null +++ b/ext/standard/tests/url/base64_decode_variation_002.phpt @@ -0,0 +1,175 @@ +--TEST-- +Test base64_decode() function : usage variations - unexpected types for arg 2 +--FILE-- +<?php +/* Prototype : proto string base64_decode(string str[, bool strict]) + * Description: Decodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing base64_decode() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$str = 'aGVsbG8gd29ybGQh!'; + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array ( + // int data + "0" => 0, + "1" => 1, + "12345" => 12345, + "-2345" => -2345, + + // float data + "10.5" => 10.5, + "-10.5" => -10.5, + "10.1234567e10" => 10.1234567e10, + "10.7654321E-10" => 10.7654321E-10, + ".5" => .5, + + // array data + "array()" => array(), + "array(0)" => array(0), + "array(1)" => array(1), + "array(1, 2)" => array(1, 2), + "array('color' => 'red', 'item' => 'pen'" => array('color' => 'red', 'item' => 'pen'), + + // null data + "NULL" => NULL, + "null" => null, + + // boolean data + "true" => true, + "false" => false, + "TRUE" => TRUE, + "FALSE" => FALSE, + + // empty data + "\"\"" => "", + "''" => '', + + // object data + "stdClass object" => new stdclass(), + + // undefined data + "undefined variable" => $undefined_var, + + // unset data + "unset variable" => $unset_var, + + // resource data + "resource" => $file_handle +); + +// loop through each element of the array for strict argument + +foreach($values as $key=>$value) { + echo "\n-- Arg value $key --\n"; + var_dump(base64_decode($str, $value)); +}; + +?> +===Done=== +--EXPECTF-- +*** Testing base64_decode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(%d) +Error: 8 - Undefined variable: unset_var, %s(%d) + +-- Arg value 0 -- +string(12) "hello world!" + +-- Arg value 1 -- +bool(false) + +-- Arg value 12345 -- +bool(false) + +-- Arg value -2345 -- +bool(false) + +-- Arg value 10.5 -- +bool(false) + +-- Arg value -10.5 -- +bool(false) + +-- Arg value 10.1234567e10 -- +bool(false) + +-- Arg value 10.7654321E-10 -- +bool(false) + +-- Arg value .5 -- +bool(false) + +-- Arg value array() -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d) +NULL + +-- Arg value array(0) -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d) +NULL + +-- Arg value array(1) -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d) +NULL + +-- Arg value array(1, 2) -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d) +NULL + +-- Arg value array('color' => 'red', 'item' => 'pen' -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, array given, %s(%d) +NULL + +-- Arg value NULL -- +string(12) "hello world!" + +-- Arg value null -- +string(12) "hello world!" + +-- Arg value true -- +bool(false) + +-- Arg value false -- +string(12) "hello world!" + +-- Arg value TRUE -- +bool(false) + +-- Arg value FALSE -- +string(12) "hello world!" + +-- Arg value "" -- +string(12) "hello world!" + +-- Arg value '' -- +string(12) "hello world!" + +-- Arg value stdClass object -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, object given, %s(%d) +NULL + +-- Arg value undefined variable -- +string(12) "hello world!" + +-- Arg value unset variable -- +string(12) "hello world!" + +-- Arg value resource -- +Error: 2 - base64_decode() expects parameter 2 to be boolean, resource given, %s(%d) +NULL +===Done===
\ No newline at end of file diff --git a/ext/standard/tests/url/base64_encode_basic_001.phpt b/ext/standard/tests/url/base64_encode_basic_001.phpt new file mode 100644 index 0000000..6ab57f4 --- /dev/null +++ b/ext/standard/tests/url/base64_encode_basic_001.phpt @@ -0,0 +1,283 @@ +--TEST-- +Test base64_encode() function : basic functionality +--FILE-- +<?php +/* Prototype : proto string base64_encode(string str) + * Description: Encodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +/* + * Test base64_encode with single byte values. + */ + +echo "*** Testing base64_encode() : basic functionality ***\n"; + +for ($i=0; $i<256; $i++) { + $str = pack("c", $i); + $enc = base64_encode($str); + printf("0x%X: %s\n", $i, $enc); +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing base64_encode() : basic functionality *** +0x0: AA== +0x1: AQ== +0x2: Ag== +0x3: Aw== +0x4: BA== +0x5: BQ== +0x6: Bg== +0x7: Bw== +0x8: CA== +0x9: CQ== +0xA: Cg== +0xB: Cw== +0xC: DA== +0xD: DQ== +0xE: Dg== +0xF: Dw== +0x10: EA== +0x11: EQ== +0x12: Eg== +0x13: Ew== +0x14: FA== +0x15: FQ== +0x16: Fg== +0x17: Fw== +0x18: GA== +0x19: GQ== +0x1A: Gg== +0x1B: Gw== +0x1C: HA== +0x1D: HQ== +0x1E: Hg== +0x1F: Hw== +0x20: IA== +0x21: IQ== +0x22: Ig== +0x23: Iw== +0x24: JA== +0x25: JQ== +0x26: Jg== +0x27: Jw== +0x28: KA== +0x29: KQ== +0x2A: Kg== +0x2B: Kw== +0x2C: LA== +0x2D: LQ== +0x2E: Lg== +0x2F: Lw== +0x30: MA== +0x31: MQ== +0x32: Mg== +0x33: Mw== +0x34: NA== +0x35: NQ== +0x36: Ng== +0x37: Nw== +0x38: OA== +0x39: OQ== +0x3A: Og== +0x3B: Ow== +0x3C: PA== +0x3D: PQ== +0x3E: Pg== +0x3F: Pw== +0x40: QA== +0x41: QQ== +0x42: Qg== +0x43: Qw== +0x44: RA== +0x45: RQ== +0x46: Rg== +0x47: Rw== +0x48: SA== +0x49: SQ== +0x4A: Sg== +0x4B: Sw== +0x4C: TA== +0x4D: TQ== +0x4E: Tg== +0x4F: Tw== +0x50: UA== +0x51: UQ== +0x52: Ug== +0x53: Uw== +0x54: VA== +0x55: VQ== +0x56: Vg== +0x57: Vw== +0x58: WA== +0x59: WQ== +0x5A: Wg== +0x5B: Ww== +0x5C: XA== +0x5D: XQ== +0x5E: Xg== +0x5F: Xw== +0x60: YA== +0x61: YQ== +0x62: Yg== +0x63: Yw== +0x64: ZA== +0x65: ZQ== +0x66: Zg== +0x67: Zw== +0x68: aA== +0x69: aQ== +0x6A: ag== +0x6B: aw== +0x6C: bA== +0x6D: bQ== +0x6E: bg== +0x6F: bw== +0x70: cA== +0x71: cQ== +0x72: cg== +0x73: cw== +0x74: dA== +0x75: dQ== +0x76: dg== +0x77: dw== +0x78: eA== +0x79: eQ== +0x7A: eg== +0x7B: ew== +0x7C: fA== +0x7D: fQ== +0x7E: fg== +0x7F: fw== +0x80: gA== +0x81: gQ== +0x82: gg== +0x83: gw== +0x84: hA== +0x85: hQ== +0x86: hg== +0x87: hw== +0x88: iA== +0x89: iQ== +0x8A: ig== +0x8B: iw== +0x8C: jA== +0x8D: jQ== +0x8E: jg== +0x8F: jw== +0x90: kA== +0x91: kQ== +0x92: kg== +0x93: kw== +0x94: lA== +0x95: lQ== +0x96: lg== +0x97: lw== +0x98: mA== +0x99: mQ== +0x9A: mg== +0x9B: mw== +0x9C: nA== +0x9D: nQ== +0x9E: ng== +0x9F: nw== +0xA0: oA== +0xA1: oQ== +0xA2: og== +0xA3: ow== +0xA4: pA== +0xA5: pQ== +0xA6: pg== +0xA7: pw== +0xA8: qA== +0xA9: qQ== +0xAA: qg== +0xAB: qw== +0xAC: rA== +0xAD: rQ== +0xAE: rg== +0xAF: rw== +0xB0: sA== +0xB1: sQ== +0xB2: sg== +0xB3: sw== +0xB4: tA== +0xB5: tQ== +0xB6: tg== +0xB7: tw== +0xB8: uA== +0xB9: uQ== +0xBA: ug== +0xBB: uw== +0xBC: vA== +0xBD: vQ== +0xBE: vg== +0xBF: vw== +0xC0: wA== +0xC1: wQ== +0xC2: wg== +0xC3: ww== +0xC4: xA== +0xC5: xQ== +0xC6: xg== +0xC7: xw== +0xC8: yA== +0xC9: yQ== +0xCA: yg== +0xCB: yw== +0xCC: zA== +0xCD: zQ== +0xCE: zg== +0xCF: zw== +0xD0: 0A== +0xD1: 0Q== +0xD2: 0g== +0xD3: 0w== +0xD4: 1A== +0xD5: 1Q== +0xD6: 1g== +0xD7: 1w== +0xD8: 2A== +0xD9: 2Q== +0xDA: 2g== +0xDB: 2w== +0xDC: 3A== +0xDD: 3Q== +0xDE: 3g== +0xDF: 3w== +0xE0: 4A== +0xE1: 4Q== +0xE2: 4g== +0xE3: 4w== +0xE4: 5A== +0xE5: 5Q== +0xE6: 5g== +0xE7: 5w== +0xE8: 6A== +0xE9: 6Q== +0xEA: 6g== +0xEB: 6w== +0xEC: 7A== +0xED: 7Q== +0xEE: 7g== +0xEF: 7w== +0xF0: 8A== +0xF1: 8Q== +0xF2: 8g== +0xF3: 8w== +0xF4: 9A== +0xF5: 9Q== +0xF6: 9g== +0xF7: 9w== +0xF8: +A== +0xF9: +Q== +0xFA: +g== +0xFB: +w== +0xFC: /A== +0xFD: /Q== +0xFE: /g== +0xFF: /w== +Done diff --git a/ext/standard/tests/url/base64_encode_basic_002.phpt b/ext/standard/tests/url/base64_encode_basic_002.phpt new file mode 100644 index 0000000..cff8f41 --- /dev/null +++ b/ext/standard/tests/url/base64_encode_basic_002.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test base64_encode() function : basic functionality - check algorithm round trips +--FILE-- +<?php +/* Prototype : proto string base64_encode(string str) + * Description: Encodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +/* + * Test base64_encode with single byte values. + */ + +echo "*** Testing base64_encode() : basic functionality ***\n"; + +$values = array( + "Hello World", + "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!%^&*(){}[]", + "\n\t Line with control characters\r\n", + "\xC1\xC2\xC3\xC4\xC5\xC6", + "\75\76\77\78\79\80" +); + +echo "\n--- Testing base64_encode() with binary string input ---\n"; + +$counter = 1; +foreach($values as $str) { + echo "-- Iteration $counter --\n"; + + $enc = base64_encode($str); + $dec = base64_decode($enc); + + if ($dec != $str) { + echo "TEST FAILED\n"; + } else { + echo "TEST PASSED\n"; + } + + $counter ++; +} + +?> +===Done=== +--EXPECTF-- +*** Testing base64_encode() : basic functionality *** + +--- Testing base64_encode() with binary string input --- +-- Iteration 1 -- +TEST PASSED +-- Iteration 2 -- +TEST PASSED +-- Iteration 3 -- +TEST PASSED +-- Iteration 4 -- +TEST PASSED +-- Iteration 5 -- +TEST PASSED +===Done=== diff --git a/ext/standard/tests/url/base64_encode_error_001.phpt b/ext/standard/tests/url/base64_encode_error_001.phpt new file mode 100644 index 0000000..a8883ac --- /dev/null +++ b/ext/standard/tests/url/base64_encode_error_001.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test base64_encode() function : error conditions - wrong number of args +--FILE-- +<?php +/* Prototype : proto string base64_encode(string str) + * Description: Encodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +echo "*** Testing base64_encode() : error conditions - wrong number of args ***\n"; + +// Zero arguments +echo "\n-- Testing base64_encode() function with Zero arguments --\n"; +var_dump( base64_encode() ); + +//Test base64_encode with one more than the expected number of arguments +echo "\n-- Testing base64_encode() function with more than expected no. of arguments --\n"; +$str = 'string_val'; +$extra_arg = 10; +var_dump( base64_encode($str, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing base64_encode() : error conditions - wrong number of args *** + +-- Testing base64_encode() function with Zero arguments -- + +Warning: base64_encode() expects exactly 1 parameter, 0 given in %s on line 12 +NULL + +-- Testing base64_encode() function with more than expected no. of arguments -- + +Warning: base64_encode() expects exactly 1 parameter, 2 given in %s on line 18 +NULL +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/base64_encode_variation_001.phpt b/ext/standard/tests/url/base64_encode_variation_001.phpt new file mode 100644 index 0000000..f632beb --- /dev/null +++ b/ext/standard/tests/url/base64_encode_variation_001.phpt @@ -0,0 +1,172 @@ +--TEST-- +Test base64_encode() function : usage variations - unexpected types for argument 1 +--FILE-- +<?php +/* Prototype : proto string base64_encode(string str) + * Description: Encodes string using MIME base64 algorithm + * Source code: ext/standard/base64.c + * Alias to functions: + */ + +echo "*** Testing base64_encode() : usage variations ***\n"; + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for str + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( base64_encode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing base64_encode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(63) +Error: 8 - Undefined variable: unset_var, %s(66) + +Arg value 0 +string(4) "MA==" + +Arg value 1 +string(4) "MQ==" + +Arg value 12345 +string(8) "MTIzNDU=" + +Arg value -2345 +string(8) "LTIzNDU=" + +Arg value 10.5 +string(8) "MTAuNQ==" + +Arg value -10.5 +string(8) "LTEwLjU=" + +Arg value 101234567000 +string(16) "MTAxMjM0NTY3MDAw" + +Arg value 1.07654321E-9 +string(20) "MS4wNzY1NDMyMUUtOQ==" + +Arg value 0.5 +string(4) "MC41" +Error: 8 - Array to string conversion, %sbase64_encode_variation_001.php(%d) + +Arg value Array +Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73) +NULL +Error: 8 - Array to string conversion, %sbase64_encode_variation_001.php(%d) + +Arg value Array +Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73) +NULL +Error: 8 - Array to string conversion, %sbase64_encode_variation_001.php(%d) + +Arg value Array +Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73) +NULL +Error: 8 - Array to string conversion, %sbase64_encode_variation_001.php(%d) + +Arg value Array +Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73) +NULL +Error: 8 - Array to string conversion, %sbase64_encode_variation_001.php(%d) + +Arg value Array +Error: 2 - base64_encode() expects parameter 1 to be string, array given, %s(73) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(4) "MQ==" + +Arg value +string(0) "" + +Arg value 1 +string(4) "MQ==" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" +Error: 4096 - Object of class stdClass could not be converted to string, %s(72) + +Arg value +Error: 2 - base64_encode() expects parameter 1 to be string, object given, %s(73) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" +Done diff --git a/ext/standard/tests/url/bug47174.phpt b/ext/standard/tests/url/bug47174.phpt new file mode 100644 index 0000000..0296dbe --- /dev/null +++ b/ext/standard/tests/url/bug47174.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #47174 (base64_decode() interprets pad char in mid string as terminator) +--FILE-- +<?php +if (base64_decode(b"dGVzdA==") == base64_decode(b"dGVzdA==CRAP")) { + echo "Same octect data - Signature Valid\n"; +} else { + echo "Invalid Signature\n"; +} + +$in = base64_encode(b"foo") . b'==' . base64_encode(b"bar"); +var_dump($in, base64_decode($in)); + +?> +--EXPECT-- +Invalid Signature +string(10) "Zm9v==YmFy" +string(6) "foobar" diff --git a/ext/standard/tests/url/bug52327.phpt b/ext/standard/tests/url/bug52327.phpt new file mode 100644 index 0000000..fb2e0fa --- /dev/null +++ b/ext/standard/tests/url/bug52327.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #52327 (base64_decode() improper handling of leading padding) +--FILE-- +<?php +var_dump( + base64_decode('=VGhl=ICc9=JyBz=eW1i=b2xz=IGFy=ZW4n=dCBh=bGxv=d2Vk=IHdo=ZXJl=IGkg=cHV0=IHRo=ZW0g=by5P'), + base64_decode('=VGhl=ICc9=JyBz=eW1i=b2xz=IGFy=ZW4n=dCBh=bGxv=d2Vk=IHdo=ZXJl=IGkg=cHV0=IHRo=ZW0g=by5P', true) +); +?> +--EXPECT-- +string(51) "The '=' symbols aren't allowed where i put them o.O" +bool(false) diff --git a/ext/standard/tests/url/bug53248.phpt b/ext/standard/tests/url/bug53248.phpt new file mode 100644 index 0000000..5e31c51 --- /dev/null +++ b/ext/standard/tests/url/bug53248.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #53248 (rawurlencode RFC 3986 EBCDIC support) +--FILE-- +<?php + +var_dump(rawurlencode('A1_-.~')); +var_dump(rawurldecode('%41%31%5F%2D%2E%7E')); + +?> +--EXPECTF-- +string(6) "A1_-.~" +string(6) "A1_-.~"
\ No newline at end of file diff --git a/ext/standard/tests/url/bug54180.phpt b/ext/standard/tests/url/bug54180.phpt new file mode 100644 index 0000000..2e64e27 --- /dev/null +++ b/ext/standard/tests/url/bug54180.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #54180 (parse_url() incorrectly parses path when ? in fragment) +--FILE-- +<?php + +var_dump(parse_url("http://example.com/path/script.html?t=1#fragment?data")); +var_dump(parse_url("http://example.com/path/script.html#fragment?data")); + +?> +--EXPECTF-- +array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "example.com" + ["path"]=> + string(17) "/path/script.html" + ["query"]=> + string(3) "t=1" + ["fragment"]=> + string(13) "fragment?data" +} +array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "example.com" + ["path"]=> + string(17) "/path/script.html" + ["fragment"]=> + string(13) "fragment?data" +} diff --git a/ext/standard/tests/url/bug55273.phpt b/ext/standard/tests/url/bug55273.phpt new file mode 100644 index 0000000..1408506 --- /dev/null +++ b/ext/standard/tests/url/bug55273.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #55273 (base64_decode() with strict rejects whitespace after pad) +--FILE-- +<?php +function test($s) { + $v = chunk_split(base64_encode($s)); + $r = base64_decode($v, True); + var_dump($v, $r); +} + +test('PHP'); +test('PH'); +test('P'); + +?> +--EXPECT-- +string(6) "UEhQ +" +string(3) "PHP" +string(6) "UEg= +" +string(2) "PH" +string(6) "UA== +" +string(1) "P" diff --git a/ext/standard/tests/url/bug55399.phpt b/ext/standard/tests/url/bug55399.phpt new file mode 100644 index 0000000..619c08d --- /dev/null +++ b/ext/standard/tests/url/bug55399.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #55399 (parse_url() incorrectly treats ':' as a valid path) +--FILE-- +<?php + +var_dump(parse_url(":")); + +?> +--EXPECT-- +bool(false) diff --git a/ext/standard/tests/url/bug63162.phpt b/ext/standard/tests/url/bug63162.phpt new file mode 100644 index 0000000..ea5205e --- /dev/null +++ b/ext/standard/tests/url/bug63162.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test parse_url() for bug #63162 +--DESCRIPTION-- +This test covers tests the inputs: +[0]=> http://user:pass@host +[1]=> //user:pass@host +[2]=> //user@host +--FILE-- +<?php +var_dump(parse_url('http://user:pass@host')); +var_dump(parse_url('//user:pass@host')); +var_dump(parse_url('//user@host')); +?> +--EXPECT-- +array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(4) "host" + ["user"]=> + string(4) "user" + ["pass"]=> + string(4) "pass" +} +array(3) { + ["host"]=> + string(4) "host" + ["user"]=> + string(4) "user" + ["pass"]=> + string(4) "pass" +} +array(2) { + ["host"]=> + string(4) "host" + ["user"]=> + string(4) "user" +} diff --git a/ext/standard/tests/url/get_headers_error_001.phpt b/ext/standard/tests/url/get_headers_error_001.phpt new file mode 100644 index 0000000..8d5fd11 --- /dev/null +++ b/ext/standard/tests/url/get_headers_error_001.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test get_headers() function : error conditions - wrong number of args +--CREDITS-- +June Henriksen <juneih@redpill-linpro.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--FILE-- +<?php +/* Prototype : proto array get_headers(string url[, int format]) + * Description: Fetches all the headers sent by the server in response to a HTTP request + * Source code: ext/standard/url.c + * Alias to functions: + */ + +echo "*** Testing get_headers() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing get_headers() function with Zero arguments --\n"; +var_dump( get_headers() ); + +//Test get_headers with one more than the expected number of arguments +echo "\n-- Testing get_headers() function with more than expected no. of arguments --\n"; +$url = 'string_val'; +$format = 1; +$extra_arg = 10; +var_dump( get_headers($url, $format, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing get_headers() : error conditions *** + +-- Testing get_headers() function with Zero arguments -- + +Warning: get_headers() expects at least 1 parameter, 0 given in %s on line 12 +NULL + +-- Testing get_headers() function with more than expected no. of arguments -- + +Warning: get_headers() expects at most 2 parameters, 3 given in %s on line 19 +NULL +Done + + + diff --git a/ext/standard/tests/url/get_headers_error_002.phpt b/ext/standard/tests/url/get_headers_error_002.phpt new file mode 100644 index 0000000..9626211 --- /dev/null +++ b/ext/standard/tests/url/get_headers_error_002.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test get_headers() function: wrong type for argument format +--CREDITS-- +June Henriksen <juneih@redpill-linpro.com> +#PHPTestFest2009 Norway 2009-06-09 \o/ +--FILE-- +<?php +/* Prototype : proto array get_headers(string url[, int format]) + * Description: Fetches all the headers sent by the server in response to a HTTP request + * Source code: ext/standard/url.c + * Alias to functions: + */ + +echo "*** Testing get_headers() : error conditions ***\n"; +$url = 'http://php.net'; + +// Format argument as type String +echo "\n-- Testing get_headers() function with format argument as type string --\n"; +var_dump( get_headers($url, "#PHPTestFest2009 Norway") ); + +// Format argument as type Array +echo "\n-- Testing get_headers() function with format argument as type array --\n"; +var_dump( get_headers($url, array()) ); + +// Format argument as type Object +class testObject +{ +} + +$object = new testObject(); +echo "\n-- Testing get_headers() function with format argument as type object --\n"; +var_dump( get_headers($url, $object) ); + + +echo "Done" +?> +--EXPECTF-- +*** Testing get_headers() : error conditions *** + +-- Testing get_headers() function with format argument as type string -- + +Warning: get_headers() expects parameter 2 to be long, string given in %s on line 13 +NULL + +-- Testing get_headers() function with format argument as type array -- + +Warning: get_headers() expects parameter 2 to be long, array given in %s on line 17 +NULL + +-- Testing get_headers() function with format argument as type object -- + +Warning: get_headers() expects parameter 2 to be long, object given in %s on line 26 +NULL +Done + diff --git a/ext/standard/tests/url/parse_url_basic_001.phpt b/ext/standard/tests/url/parse_url_basic_001.phpt new file mode 100644 index 0000000..1edc32e --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_001.phpt @@ -0,0 +1,866 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying the component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying the component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "\n--> $url: "; + var_dump(parse_url($url)); +} + +echo "Done"; +?> +--EXPECTF-- + +--> 64.246.30.37: array(1) { + ["path"]=> + string(12) "64.246.30.37" +} + +--> http://64.246.30.37: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(12) "64.246.30.37" +} + +--> http://64.246.30.37/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(12) "64.246.30.37" + ["path"]=> + string(1) "/" +} + +--> 64.246.30.37/: array(1) { + ["path"]=> + string(13) "64.246.30.37/" +} + +--> 64.246.30.37:80/: array(3) { + ["host"]=> + string(12) "64.246.30.37" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> php.net: array(1) { + ["path"]=> + string(7) "php.net" +} + +--> php.net/: array(1) { + ["path"]=> + string(8) "php.net/" +} + +--> http://php.net: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "php.net" +} + +--> http://php.net/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "php.net" + ["path"]=> + string(1) "/" +} + +--> www.php.net: array(1) { + ["path"]=> + string(11) "www.php.net" +} + +--> www.php.net/: array(1) { + ["path"]=> + string(12) "www.php.net/" +} + +--> http://www.php.net: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" +} + +--> http://www.php.net/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(1) "/" +} + +--> www.php.net:80: array(2) { + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) +} + +--> http://www.php.net:80: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) +} + +--> http://www.php.net:80/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net/index.php: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(10) "/index.php" +} + +--> www.php.net/?: array(1) { + ["path"]=> + string(12) "www.php.net/" +} + +--> www.php.net:80/?: array(3) { + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net/?: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(1) "/" +} + +--> http://www.php.net:80/?: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net:80/index.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" +} + +--> http://www.php.net:80/foo/bar/index.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(18) "/foo/bar/index.php" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(53) "/this/is/a/very/deep/directory/structure/and/file.php" + ["query"]=> + string(37) "lots=1&of=2¶meters=3&too=4&here=5" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(45) "/this/is/a/very/deep/directory/structure/and/" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +} + +--> http://www.php.net:80/this/../a/../deep/directory: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(28) "/this/../a/../deep/directory" +} + +--> http://www.php.net:80/this/../a/../deep/directory/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(29) "/this/../a/../deep/directory/" +} + +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(42) "/this/is/a/very/deep/directory/../file.php" +} + +--> http://www.php.net:80/index.php: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" +} + +--> http://www.php.net:80/index.php?: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" +} + +--> http://www.php.net:80/#foo: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" + ["fragment"]=> + string(3) "foo" +} + +--> http://www.php.net:80/?#: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" +} + +--> http://www.php.net:80/?test=1: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" + ["query"]=> + string(6) "test=1" +} + +--> http://www.php.net/?test=1&: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(1) "/" + ["query"]=> + string(7) "test=1&" +} + +--> http://www.php.net:80/?&: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(1) "/" + ["query"]=> + string(1) "&" +} + +--> http://www.php.net:80/index.php?test=1&: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(7) "test=1&" +} + +--> http://www.php.net/index.php?&: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(1) "&" +} + +--> http://www.php.net:80/index.php?foo&: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(4) "foo&" +} + +--> http://www.php.net/index.php?&foo: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(4) "&foo" +} + +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" +} + +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) { + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(6) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["user"]=> + string(6) "secret" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(14) "secret@hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hid:out" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +--> nntp://news.php.net: array(2) { + ["scheme"]=> + string(4) "nntp" + ["host"]=> + string(12) "news.php.net" +} + +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) { + ["scheme"]=> + string(3) "ftp" + ["host"]=> + string(11) "ftp.gnu.org" + ["path"]=> + string(22) "/gnu/glic/glibc.tar.gz" +} + +--> zlib:http://foo@bar: array(2) { + ["scheme"]=> + string(4) "zlib" + ["path"]=> + string(14) "http://foo@bar" +} + +--> zlib:filename.txt: array(2) { + ["scheme"]=> + string(4) "zlib" + ["path"]=> + string(12) "filename.txt" +} + +--> zlib:/path/to/my/file/file.txt: array(2) { + ["scheme"]=> + string(4) "zlib" + ["path"]=> + string(25) "/path/to/my/file/file.txt" +} + +--> foo://foo@bar: array(3) { + ["scheme"]=> + string(3) "foo" + ["host"]=> + string(3) "bar" + ["user"]=> + string(3) "foo" +} + +--> mailto:me@mydomain.com: array(2) { + ["scheme"]=> + string(6) "mailto" + ["path"]=> + string(15) "me@mydomain.com" +} + +--> /foo.php?a=b&c=d: array(2) { + ["path"]=> + string(8) "/foo.php" + ["query"]=> + string(7) "a=b&c=d" +} + +--> foo.php?a=b&c=d: array(2) { + ["path"]=> + string(7) "foo.php" + ["query"]=> + string(7) "a=b&c=d" +} + +--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(15) "www.example.com" + ["port"]=> + int(8080) + ["user"]=> + string(4) "user" + ["pass"]=> + string(6) "passwd" + ["query"]=> + string(12) "bar=1&boom=0" +} + +--> file:///path/to/file: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(13) "/path/to/file" +} + +--> file://path/to/file: array(3) { + ["scheme"]=> + string(4) "file" + ["host"]=> + string(4) "path" + ["path"]=> + string(8) "/to/file" +} + +--> file:/path/to/file: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(13) "/path/to/file" +} + +--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "1.2.3.4" + ["path"]=> + string(8) "/abc.asp" + ["query"]=> + string(7) "a=1&b=2" +} + +--> http://foo.com#bar: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(7) "foo.com" + ["fragment"]=> + string(3) "bar" +} + +--> scheme:: array(1) { + ["scheme"]=> + string(6) "scheme" +} + +--> foo+bar://baz@bang/bla: array(4) { + ["scheme"]=> + string(7) "foo+bar" + ["host"]=> + string(4) "bang" + ["user"]=> + string(3) "baz" + ["path"]=> + string(4) "/bla" +} + +--> gg:9130731: array(2) { + ["scheme"]=> + string(2) "gg" + ["path"]=> + string(7) "9130731" +} + +--> http://user:@pass@host/path?argument?value#etc: array(7) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(4) "host" + ["user"]=> + string(4) "user" + ["pass"]=> + string(5) "@pass" + ["path"]=> + string(5) "/path" + ["query"]=> + string(14) "argument?value" + ["fragment"]=> + string(3) "etc" +} + +--> http://10.10.10.10/:80: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "10.10.10.10" + ["path"]=> + string(4) "/:80" +} + +--> http://x:?: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) "x" +} + +--> x:blah.com: array(2) { + ["scheme"]=> + string(1) "x" + ["path"]=> + string(8) "blah.com" +} + +--> x:/blah.com: array(2) { + ["scheme"]=> + string(1) "x" + ["path"]=> + string(9) "/blah.com" +} + +--> x://::abc/?: bool(false) + +--> http://::?: array(2) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) ":" +} + +--> x://::6.5: array(3) { + ["scheme"]=> + string(1) "x" + ["host"]=> + string(1) ":" + ["port"]=> + int(6) +} + +--> http://?:/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) "?" + ["path"]=> + string(1) "/" +} + +--> http://@?:/: array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(1) "?" + ["user"]=> + string(0) "" + ["path"]=> + string(1) "/" +} + +--> file:///:: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(2) "/:" +} + +--> file:///a:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(3) "a:/" +} + +--> file:///ab:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(5) "/ab:/" +} + +--> file:///a:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(3) "a:/" +} + +--> file:///@:/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(3) "@:/" +} + +--> file:///:80/: array(2) { + ["scheme"]=> + string(4) "file" + ["path"]=> + string(5) "/:80/" +} + +--> []: array(1) { + ["path"]=> + string(2) "[]" +} + +--> http://[x:80]/: array(3) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(6) "[x:80]" + ["path"]=> + string(1) "/" +} + +--> : array(1) { + ["path"]=> + string(0) "" +} + +--> /: array(1) { + ["path"]=> + string(1) "/" +} + +--> http:///blah.com: bool(false) + +--> http://:80: bool(false) + +--> http://user@:80: bool(false) + +--> http://user:pass@:80: bool(false) + +--> http://:: bool(false) + +--> http://@/: bool(false) + +--> http://@:/: bool(false) + +--> http://:/: bool(false) + +--> http://?: bool(false) + +--> http://?:: bool(false) + +--> http://:?: bool(false) + +--> http://blah.com:123456: bool(false) + +--> http://blah.com:abcdef: bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_002.phpt b/ext/standard/tests/url/parse_url_basic_002.phpt new file mode 100644 index 0000000..464e977 --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_002.phpt @@ -0,0 +1,125 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_SCHEME as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_SCHEME as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_SCHEME)); + +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : string(4) "http" +--> http://64.246.30.37/ : string(4) "http" +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : NULL +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : string(4) "http" +--> http://php.net/ : string(4) "http" +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : string(4) "http" +--> http://www.php.net/ : string(4) "http" +--> www.php.net:80 : NULL +--> http://www.php.net:80 : string(4) "http" +--> http://www.php.net:80/ : string(4) "http" +--> http://www.php.net/index.php : string(4) "http" +--> www.php.net/? : NULL +--> www.php.net:80/? : NULL +--> http://www.php.net/? : string(4) "http" +--> http://www.php.net:80/? : string(4) "http" +--> http://www.php.net:80/index.php : string(4) "http" +--> http://www.php.net:80/foo/bar/index.php : string(4) "http" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(4) "http" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : string(4) "http" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : string(4) "http" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(4) "http" +--> http://www.php.net:80/this/../a/../deep/directory : string(4) "http" +--> http://www.php.net:80/this/../a/../deep/directory/ : string(4) "http" +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : string(4) "http" +--> http://www.php.net:80/index.php : string(4) "http" +--> http://www.php.net:80/index.php? : string(4) "http" +--> http://www.php.net:80/#foo : string(4) "http" +--> http://www.php.net:80/?# : string(4) "http" +--> http://www.php.net:80/?test=1 : string(4) "http" +--> http://www.php.net/?test=1& : string(4) "http" +--> http://www.php.net:80/?& : string(4) "http" +--> http://www.php.net:80/index.php?test=1& : string(4) "http" +--> http://www.php.net/index.php?& : string(4) "http" +--> http://www.php.net:80/index.php?foo& : string(4) "http" +--> http://www.php.net/index.php?&foo : string(4) "http" +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(4) "http" +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http" +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http" +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http" +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http" +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(4) "http" +--> nntp://news.php.net : string(4) "nntp" +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : string(3) "ftp" +--> zlib:http://foo@bar : string(4) "zlib" +--> zlib:filename.txt : string(4) "zlib" +--> zlib:/path/to/my/file/file.txt : string(4) "zlib" +--> foo://foo@bar : string(3) "foo" +--> mailto:me@mydomain.com : string(6) "mailto" +--> /foo.php?a=b&c=d : NULL +--> foo.php?a=b&c=d : NULL +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(4) "http" +--> file:///path/to/file : string(4) "file" +--> file://path/to/file : string(4) "file" +--> file:/path/to/file : string(4) "file" +--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(4) "http" +--> http://foo.com#bar : string(4) "http" +--> scheme: : string(6) "scheme" +--> foo+bar://baz@bang/bla : string(7) "foo+bar" +--> gg:9130731 : string(2) "gg" +--> http://user:@pass@host/path?argument?value#etc : string(4) "http" +--> http://10.10.10.10/:80 : string(4) "http" +--> http://x:? : string(4) "http" +--> x:blah.com : string(1) "x" +--> x:/blah.com : string(1) "x" +--> x://::abc/? : bool(false) +--> http://::? : string(4) "http" +--> x://::6.5 : string(1) "x" +--> http://?:/ : string(4) "http" +--> http://@?:/ : string(4) "http" +--> file:///: : string(4) "file" +--> file:///a:/ : string(4) "file" +--> file:///ab:/ : string(4) "file" +--> file:///a:/ : string(4) "file" +--> file:///@:/ : string(4) "file" +--> file:///:80/ : string(4) "file" +--> [] : NULL +--> http://[x:80]/ : string(4) "http" +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_003.phpt b/ext/standard/tests/url/parse_url_basic_003.phpt new file mode 100644 index 0000000..57f182b --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_003.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_HOST as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_HOST as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_HOST)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : string(12) "64.246.30.37" +--> http://64.246.30.37/ : string(12) "64.246.30.37" +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : string(12) "64.246.30.37" +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : string(7) "php.net" +--> http://php.net/ : string(7) "php.net" +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : string(11) "www.php.net" +--> http://www.php.net/ : string(11) "www.php.net" +--> www.php.net:80 : string(11) "www.php.net" +--> http://www.php.net:80 : string(11) "www.php.net" +--> http://www.php.net:80/ : string(11) "www.php.net" +--> http://www.php.net/index.php : string(11) "www.php.net" +--> www.php.net/? : NULL +--> www.php.net:80/? : string(11) "www.php.net" +--> http://www.php.net/? : string(11) "www.php.net" +--> http://www.php.net:80/? : string(11) "www.php.net" +--> http://www.php.net:80/index.php : string(11) "www.php.net" +--> http://www.php.net:80/foo/bar/index.php : string(11) "www.php.net" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(11) "www.php.net" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : string(11) "www.php.net" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : string(11) "www.php.net" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(11) "www.php.net" +--> http://www.php.net:80/this/../a/../deep/directory : string(11) "www.php.net" +--> http://www.php.net:80/this/../a/../deep/directory/ : string(11) "www.php.net" +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : string(11) "www.php.net" +--> http://www.php.net:80/index.php : string(11) "www.php.net" +--> http://www.php.net:80/index.php? : string(11) "www.php.net" +--> http://www.php.net:80/#foo : string(11) "www.php.net" +--> http://www.php.net:80/?# : string(11) "www.php.net" +--> http://www.php.net:80/?test=1 : string(11) "www.php.net" +--> http://www.php.net/?test=1& : string(11) "www.php.net" +--> http://www.php.net:80/?& : string(11) "www.php.net" +--> http://www.php.net:80/index.php?test=1& : string(11) "www.php.net" +--> http://www.php.net/index.php?& : string(11) "www.php.net" +--> http://www.php.net:80/index.php?foo& : string(11) "www.php.net" +--> http://www.php.net/index.php?&foo : string(11) "www.php.net" +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(11) "www.php.net" +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(11) "www.php.net" +--> nntp://news.php.net : string(12) "news.php.net" +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : string(11) "ftp.gnu.org" +--> zlib:http://foo@bar : NULL +--> zlib:filename.txt : NULL +--> zlib:/path/to/my/file/file.txt : NULL +--> foo://foo@bar : string(3) "bar" +--> mailto:me@mydomain.com : NULL +--> /foo.php?a=b&c=d : NULL +--> foo.php?a=b&c=d : NULL +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(15) "www.example.com" +--> file:///path/to/file : NULL +--> file://path/to/file : string(4) "path" +--> file:/path/to/file : NULL +--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(7) "1.2.3.4" +--> http://foo.com#bar : string(7) "foo.com" +--> scheme: : NULL +--> foo+bar://baz@bang/bla : string(4) "bang" +--> gg:9130731 : NULL +--> http://user:@pass@host/path?argument?value#etc : string(4) "host" +--> http://10.10.10.10/:80 : string(11) "10.10.10.10" +--> http://x:? : string(1) "x" +--> x:blah.com : NULL +--> x:/blah.com : NULL +--> x://::abc/? : bool(false) +--> http://::? : string(1) ":" +--> x://::6.5 : string(1) ":" +--> http://?:/ : string(1) "?" +--> http://@?:/ : string(1) "?" +--> file:///: : NULL +--> file:///a:/ : NULL +--> file:///ab:/ : NULL +--> file:///a:/ : NULL +--> file:///@:/ : NULL +--> file:///:80/ : NULL +--> [] : NULL +--> http://[x:80]/ : string(6) "[x:80]" +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_004.phpt b/ext/standard/tests/url/parse_url_basic_004.phpt new file mode 100644 index 0000000..6abf4ed --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_004.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PORT as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_PORT as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_PORT)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : NULL +--> http://64.246.30.37/ : NULL +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : int(80) +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : NULL +--> http://php.net/ : NULL +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : NULL +--> http://www.php.net/ : NULL +--> www.php.net:80 : int(80) +--> http://www.php.net:80 : int(80) +--> http://www.php.net:80/ : int(80) +--> http://www.php.net/index.php : NULL +--> www.php.net/? : NULL +--> www.php.net:80/? : int(80) +--> http://www.php.net/? : NULL +--> http://www.php.net:80/? : int(80) +--> http://www.php.net:80/index.php : int(80) +--> http://www.php.net:80/foo/bar/index.php : int(80) +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : int(80) +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : int(80) +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : int(80) +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : int(80) +--> http://www.php.net:80/this/../a/../deep/directory : int(80) +--> http://www.php.net:80/this/../a/../deep/directory/ : int(80) +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : int(80) +--> http://www.php.net:80/index.php : int(80) +--> http://www.php.net:80/index.php? : int(80) +--> http://www.php.net:80/#foo : int(80) +--> http://www.php.net:80/?# : int(80) +--> http://www.php.net:80/?test=1 : int(80) +--> http://www.php.net/?test=1& : NULL +--> http://www.php.net:80/?& : int(80) +--> http://www.php.net:80/index.php?test=1& : int(80) +--> http://www.php.net/index.php?& : NULL +--> http://www.php.net:80/index.php?foo& : int(80) +--> http://www.php.net/index.php?&foo : NULL +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : int(80) +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80) +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80) +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80) +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80) +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : int(80) +--> nntp://news.php.net : NULL +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL +--> zlib:http://foo@bar : NULL +--> zlib:filename.txt : NULL +--> zlib:/path/to/my/file/file.txt : NULL +--> foo://foo@bar : NULL +--> mailto:me@mydomain.com : NULL +--> /foo.php?a=b&c=d : NULL +--> foo.php?a=b&c=d : NULL +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : int(8080) +--> file:///path/to/file : NULL +--> file://path/to/file : NULL +--> file:/path/to/file : NULL +--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL +--> http://foo.com#bar : NULL +--> scheme: : NULL +--> foo+bar://baz@bang/bla : NULL +--> gg:9130731 : NULL +--> http://user:@pass@host/path?argument?value#etc : NULL +--> http://10.10.10.10/:80 : NULL +--> http://x:? : NULL +--> x:blah.com : NULL +--> x:/blah.com : NULL +--> x://::abc/? : bool(false) +--> http://::? : NULL +--> x://::6.5 : int(6) +--> http://?:/ : NULL +--> http://@?:/ : NULL +--> file:///: : NULL +--> file:///a:/ : NULL +--> file:///ab:/ : NULL +--> file:///a:/ : NULL +--> file:///@:/ : NULL +--> file:///:80/ : NULL +--> [] : NULL +--> http://[x:80]/ : NULL +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_005.phpt b/ext/standard/tests/url/parse_url_basic_005.phpt new file mode 100644 index 0000000..3bcc891 --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_005.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_USER as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_USER as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_USER)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : NULL +--> http://64.246.30.37/ : NULL +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : NULL +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : NULL +--> http://php.net/ : NULL +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : NULL +--> http://www.php.net/ : NULL +--> www.php.net:80 : NULL +--> http://www.php.net:80 : NULL +--> http://www.php.net:80/ : NULL +--> http://www.php.net/index.php : NULL +--> www.php.net/? : NULL +--> www.php.net:80/? : NULL +--> http://www.php.net/? : NULL +--> http://www.php.net:80/? : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/foo/bar/index.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/../a/../deep/directory : NULL +--> http://www.php.net:80/this/../a/../deep/directory/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/index.php? : NULL +--> http://www.php.net:80/#foo : NULL +--> http://www.php.net:80/?# : NULL +--> http://www.php.net:80/?test=1 : NULL +--> http://www.php.net/?test=1& : NULL +--> http://www.php.net:80/?& : NULL +--> http://www.php.net:80/index.php?test=1& : NULL +--> http://www.php.net/index.php?& : NULL +--> http://www.php.net:80/index.php?foo& : NULL +--> http://www.php.net/index.php?&foo : NULL +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret" +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret" +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(14) "secret@hideout" +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(6) "secret" +--> nntp://news.php.net : NULL +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL +--> zlib:http://foo@bar : NULL +--> zlib:filename.txt : NULL +--> zlib:/path/to/my/file/file.txt : NULL +--> foo://foo@bar : string(3) "foo" +--> mailto:me@mydomain.com : NULL +--> /foo.php?a=b&c=d : NULL +--> foo.php?a=b&c=d : NULL +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(4) "user" +--> file:///path/to/file : NULL +--> file://path/to/file : NULL +--> file:/path/to/file : NULL +--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL +--> http://foo.com#bar : NULL +--> scheme: : NULL +--> foo+bar://baz@bang/bla : string(3) "baz" +--> gg:9130731 : NULL +--> http://user:@pass@host/path?argument?value#etc : string(4) "user" +--> http://10.10.10.10/:80 : NULL +--> http://x:? : NULL +--> x:blah.com : NULL +--> x:/blah.com : NULL +--> x://::abc/? : bool(false) +--> http://::? : NULL +--> x://::6.5 : NULL +--> http://?:/ : NULL +--> http://@?:/ : string(0) "" +--> file:///: : NULL +--> file:///a:/ : NULL +--> file:///ab:/ : NULL +--> file:///a:/ : NULL +--> file:///@:/ : NULL +--> file:///:80/ : NULL +--> [] : NULL +--> http://[x:80]/ : NULL +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_006.phpt b/ext/standard/tests/url/parse_url_basic_006.phpt new file mode 100644 index 0000000..741a424 --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_006.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PASS as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_PASS as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_PASS)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : NULL +--> http://64.246.30.37/ : NULL +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : NULL +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : NULL +--> http://php.net/ : NULL +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : NULL +--> http://www.php.net/ : NULL +--> www.php.net:80 : NULL +--> http://www.php.net:80 : NULL +--> http://www.php.net:80/ : NULL +--> http://www.php.net/index.php : NULL +--> www.php.net/? : NULL +--> www.php.net:80/? : NULL +--> http://www.php.net/? : NULL +--> http://www.php.net:80/? : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/foo/bar/index.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/../a/../deep/directory : NULL +--> http://www.php.net:80/this/../a/../deep/directory/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/index.php? : NULL +--> http://www.php.net:80/#foo : NULL +--> http://www.php.net:80/?# : NULL +--> http://www.php.net:80/?test=1 : NULL +--> http://www.php.net/?test=1& : NULL +--> http://www.php.net:80/?& : NULL +--> http://www.php.net:80/index.php?test=1& : NULL +--> http://www.php.net/index.php?& : NULL +--> http://www.php.net:80/index.php?foo& : NULL +--> http://www.php.net/index.php?&foo : NULL +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout" +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hideout" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : NULL +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(7) "hid:out" +--> nntp://news.php.net : NULL +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL +--> zlib:http://foo@bar : NULL +--> zlib:filename.txt : NULL +--> zlib:/path/to/my/file/file.txt : NULL +--> foo://foo@bar : NULL +--> mailto:me@mydomain.com : NULL +--> /foo.php?a=b&c=d : NULL +--> foo.php?a=b&c=d : NULL +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(6) "passwd" +--> file:///path/to/file : NULL +--> file://path/to/file : NULL +--> file:/path/to/file : NULL +--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL +--> http://foo.com#bar : NULL +--> scheme: : NULL +--> foo+bar://baz@bang/bla : NULL +--> gg:9130731 : NULL +--> http://user:@pass@host/path?argument?value#etc : string(5) "@pass" +--> http://10.10.10.10/:80 : NULL +--> http://x:? : NULL +--> x:blah.com : NULL +--> x:/blah.com : NULL +--> x://::abc/? : bool(false) +--> http://::? : NULL +--> x://::6.5 : NULL +--> http://?:/ : NULL +--> http://@?:/ : NULL +--> file:///: : NULL +--> file:///a:/ : NULL +--> file:///ab:/ : NULL +--> file:///a:/ : NULL +--> file:///@:/ : NULL +--> file:///:80/ : NULL +--> [] : NULL +--> http://[x:80]/ : NULL +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_007.phpt b/ext/standard/tests/url/parse_url_basic_007.phpt new file mode 100644 index 0000000..bf8f980 --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_007.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PATH as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_PATH as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_PATH)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : string(12) "64.246.30.37" +--> http://64.246.30.37 : NULL +--> http://64.246.30.37/ : string(1) "/" +--> 64.246.30.37/ : string(13) "64.246.30.37/" +--> 64.246.30.37:80/ : string(1) "/" +--> php.net : string(7) "php.net" +--> php.net/ : string(8) "php.net/" +--> http://php.net : NULL +--> http://php.net/ : string(1) "/" +--> www.php.net : string(11) "www.php.net" +--> www.php.net/ : string(12) "www.php.net/" +--> http://www.php.net : NULL +--> http://www.php.net/ : string(1) "/" +--> www.php.net:80 : NULL +--> http://www.php.net:80 : NULL +--> http://www.php.net:80/ : string(1) "/" +--> http://www.php.net/index.php : string(10) "/index.php" +--> www.php.net/? : string(12) "www.php.net/" +--> www.php.net:80/? : string(1) "/" +--> http://www.php.net/? : string(1) "/" +--> http://www.php.net:80/? : string(1) "/" +--> http://www.php.net:80/index.php : string(10) "/index.php" +--> http://www.php.net:80/foo/bar/index.php : string(18) "/foo/bar/index.php" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : string(45) "/this/is/a/very/deep/directory/structure/and/" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : string(53) "/this/is/a/very/deep/directory/structure/and/file.php" +--> http://www.php.net:80/this/../a/../deep/directory : string(28) "/this/../a/../deep/directory" +--> http://www.php.net:80/this/../a/../deep/directory/ : string(29) "/this/../a/../deep/directory/" +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : string(42) "/this/is/a/very/deep/directory/../file.php" +--> http://www.php.net:80/index.php : string(10) "/index.php" +--> http://www.php.net:80/index.php? : string(10) "/index.php" +--> http://www.php.net:80/#foo : string(1) "/" +--> http://www.php.net:80/?# : string(1) "/" +--> http://www.php.net:80/?test=1 : string(1) "/" +--> http://www.php.net/?test=1& : string(1) "/" +--> http://www.php.net:80/?& : string(1) "/" +--> http://www.php.net:80/index.php?test=1& : string(10) "/index.php" +--> http://www.php.net/index.php?& : string(10) "/index.php" +--> http://www.php.net:80/index.php?foo& : string(10) "/index.php" +--> http://www.php.net/index.php?&foo : string(10) "/index.php" +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(10) "/index.php" +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(10) "/index.php" +--> nntp://news.php.net : NULL +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : string(22) "/gnu/glic/glibc.tar.gz" +--> zlib:http://foo@bar : string(14) "http://foo@bar" +--> zlib:filename.txt : string(12) "filename.txt" +--> zlib:/path/to/my/file/file.txt : string(25) "/path/to/my/file/file.txt" +--> foo://foo@bar : NULL +--> mailto:me@mydomain.com : string(15) "me@mydomain.com" +--> /foo.php?a=b&c=d : string(8) "/foo.php" +--> foo.php?a=b&c=d : string(7) "foo.php" +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : NULL +--> file:///path/to/file : string(13) "/path/to/file" +--> file://path/to/file : string(8) "/to/file" +--> file:/path/to/file : string(13) "/path/to/file" +--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(8) "/abc.asp" +--> http://foo.com#bar : NULL +--> scheme: : NULL +--> foo+bar://baz@bang/bla : string(4) "/bla" +--> gg:9130731 : string(7) "9130731" +--> http://user:@pass@host/path?argument?value#etc : string(5) "/path" +--> http://10.10.10.10/:80 : string(4) "/:80" +--> http://x:? : NULL +--> x:blah.com : string(8) "blah.com" +--> x:/blah.com : string(9) "/blah.com" +--> x://::abc/? : bool(false) +--> http://::? : NULL +--> x://::6.5 : NULL +--> http://?:/ : string(1) "/" +--> http://@?:/ : string(1) "/" +--> file:///: : string(2) "/:" +--> file:///a:/ : string(3) "a:/" +--> file:///ab:/ : string(5) "/ab:/" +--> file:///a:/ : string(3) "a:/" +--> file:///@:/ : string(3) "@:/" +--> file:///:80/ : string(5) "/:80/" +--> [] : string(2) "[]" +--> http://[x:80]/ : string(1) "/" +--> : string(0) "" +--> / : string(1) "/" +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_008.phpt b/ext/standard/tests/url/parse_url_basic_008.phpt new file mode 100644 index 0000000..a61fd06 --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_008.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_QUERY as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_QUERY as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_QUERY)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : NULL +--> http://64.246.30.37/ : NULL +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : NULL +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : NULL +--> http://php.net/ : NULL +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : NULL +--> http://www.php.net/ : NULL +--> www.php.net:80 : NULL +--> http://www.php.net:80 : NULL +--> http://www.php.net:80/ : NULL +--> http://www.php.net/index.php : NULL +--> www.php.net/? : NULL +--> www.php.net:80/? : NULL +--> http://www.php.net/? : NULL +--> http://www.php.net:80/? : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/foo/bar/index.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : string(37) "lots=1&of=2¶meters=3&too=4&here=5" +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/../a/../deep/directory : NULL +--> http://www.php.net:80/this/../a/../deep/directory/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/index.php? : NULL +--> http://www.php.net:80/#foo : NULL +--> http://www.php.net:80/?# : NULL +--> http://www.php.net:80/?test=1 : string(6) "test=1" +--> http://www.php.net/?test=1& : string(7) "test=1&" +--> http://www.php.net:80/?& : string(1) "&" +--> http://www.php.net:80/index.php?test=1& : string(7) "test=1&" +--> http://www.php.net/index.php?& : string(1) "&" +--> http://www.php.net:80/index.php?foo& : string(4) "foo&" +--> http://www.php.net/index.php?&foo : string(4) "&foo" +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : string(31) "test=1&test2=char&test3=mixesCI" +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(31) "test=1&test2=char&test3=mixesCI" +--> nntp://news.php.net : NULL +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL +--> zlib:http://foo@bar : NULL +--> zlib:filename.txt : NULL +--> zlib:/path/to/my/file/file.txt : NULL +--> foo://foo@bar : NULL +--> mailto:me@mydomain.com : NULL +--> /foo.php?a=b&c=d : string(7) "a=b&c=d" +--> foo.php?a=b&c=d : string(7) "a=b&c=d" +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : string(12) "bar=1&boom=0" +--> file:///path/to/file : NULL +--> file://path/to/file : NULL +--> file:/path/to/file : NULL +--> http://1.2.3.4:/abc.asp?a=1&b=2 : string(7) "a=1&b=2" +--> http://foo.com#bar : NULL +--> scheme: : NULL +--> foo+bar://baz@bang/bla : NULL +--> gg:9130731 : NULL +--> http://user:@pass@host/path?argument?value#etc : string(14) "argument?value" +--> http://10.10.10.10/:80 : NULL +--> http://x:? : NULL +--> x:blah.com : NULL +--> x:/blah.com : NULL +--> x://::abc/? : bool(false) +--> http://::? : NULL +--> x://::6.5 : NULL +--> http://?:/ : NULL +--> http://@?:/ : NULL +--> file:///: : NULL +--> file:///a:/ : NULL +--> file:///ab:/ : NULL +--> file:///a:/ : NULL +--> file:///@:/ : NULL +--> file:///:80/ : NULL +--> [] : NULL +--> http://[x:80]/ : NULL +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_009.phpt b/ext/standard/tests/url/parse_url_basic_009.phpt new file mode 100644 index 0000000..5302388 --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_009.phpt @@ -0,0 +1,124 @@ +--TEST-- +Test parse_url() function: Parse a load of URLs without specifying PHP_URL_FRAGMENT as the URL component +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * Parse a load of URLs without specifying PHP_URL_FRAGMENT as the URL component + */ +include_once(dirname(__FILE__) . '/urls.inc'); + +foreach ($urls as $url) { + echo "--> $url : "; + var_dump(parse_url($url, PHP_URL_FRAGMENT)); +} + +echo "Done"; +?> +--EXPECTF-- +--> 64.246.30.37 : NULL +--> http://64.246.30.37 : NULL +--> http://64.246.30.37/ : NULL +--> 64.246.30.37/ : NULL +--> 64.246.30.37:80/ : NULL +--> php.net : NULL +--> php.net/ : NULL +--> http://php.net : NULL +--> http://php.net/ : NULL +--> www.php.net : NULL +--> www.php.net/ : NULL +--> http://www.php.net : NULL +--> http://www.php.net/ : NULL +--> www.php.net:80 : NULL +--> http://www.php.net:80 : NULL +--> http://www.php.net:80/ : NULL +--> http://www.php.net/index.php : NULL +--> www.php.net/? : NULL +--> www.php.net:80/? : NULL +--> http://www.php.net/? : NULL +--> http://www.php.net:80/? : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/foo/bar/index.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5 : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php : NULL +--> http://www.php.net:80/this/../a/../deep/directory : NULL +--> http://www.php.net:80/this/../a/../deep/directory/ : NULL +--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php : NULL +--> http://www.php.net:80/index.php : NULL +--> http://www.php.net:80/index.php? : NULL +--> http://www.php.net:80/#foo : string(3) "foo" +--> http://www.php.net:80/?# : NULL +--> http://www.php.net:80/?test=1 : NULL +--> http://www.php.net/?test=1& : NULL +--> http://www.php.net:80/?& : NULL +--> http://www.php.net:80/index.php?test=1& : NULL +--> http://www.php.net/index.php?& : NULL +--> http://www.php.net:80/index.php?foo& : NULL +--> http://www.php.net/index.php?&foo : NULL +--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI : NULL +--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123 : string(16) "some_page_ref123" +--> nntp://news.php.net : NULL +--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz : NULL +--> zlib:http://foo@bar : NULL +--> zlib:filename.txt : NULL +--> zlib:/path/to/my/file/file.txt : NULL +--> foo://foo@bar : NULL +--> mailto:me@mydomain.com : NULL +--> /foo.php?a=b&c=d : NULL +--> foo.php?a=b&c=d : NULL +--> http://user:passwd@www.example.com:8080?bar=1&boom=0 : NULL +--> file:///path/to/file : NULL +--> file://path/to/file : NULL +--> file:/path/to/file : NULL +--> http://1.2.3.4:/abc.asp?a=1&b=2 : NULL +--> http://foo.com#bar : string(3) "bar" +--> scheme: : NULL +--> foo+bar://baz@bang/bla : NULL +--> gg:9130731 : NULL +--> http://user:@pass@host/path?argument?value#etc : string(3) "etc" +--> http://10.10.10.10/:80 : NULL +--> http://x:? : NULL +--> x:blah.com : NULL +--> x:/blah.com : NULL +--> x://::abc/? : bool(false) +--> http://::? : NULL +--> x://::6.5 : NULL +--> http://?:/ : NULL +--> http://@?:/ : NULL +--> file:///: : NULL +--> file:///a:/ : NULL +--> file:///ab:/ : NULL +--> file:///a:/ : NULL +--> file:///@:/ : NULL +--> file:///:80/ : NULL +--> [] : NULL +--> http://[x:80]/ : NULL +--> : NULL +--> / : NULL +--> http:///blah.com : bool(false) +--> http://:80 : bool(false) +--> http://user@:80 : bool(false) +--> http://user:pass@:80 : bool(false) +--> http://: : bool(false) +--> http://@/ : bool(false) +--> http://@:/ : bool(false) +--> http://:/ : bool(false) +--> http://? : bool(false) +--> http://?: : bool(false) +--> http://:? : bool(false) +--> http://blah.com:123456 : bool(false) +--> http://blah.com:abcdef : bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_basic_010.phpt b/ext/standard/tests/url/parse_url_basic_010.phpt new file mode 100644 index 0000000..3bb2dba --- /dev/null +++ b/ext/standard/tests/url/parse_url_basic_010.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test parse_url() function : check values of URL related constants +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +/* + * check values of URL related constants + */ +foreach(get_defined_constants() as $constantName => $constantValue) { + if (strpos($constantName, 'PHP_URL')===0) { + echo "$constantName: $constantValue \n"; + } +} + +echo "Done"; +?> +--EXPECTF-- +PHP_URL_SCHEME: 0 +PHP_URL_HOST: 1 +PHP_URL_PORT: 2 +PHP_URL_USER: 3 +PHP_URL_PASS: 4 +PHP_URL_PATH: 5 +PHP_URL_QUERY: 6 +PHP_URL_FRAGMENT: 7 +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_error_001.phpt b/ext/standard/tests/url/parse_url_error_001.phpt new file mode 100644 index 0000000..0280a87 --- /dev/null +++ b/ext/standard/tests/url/parse_url_error_001.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test parse_url() function : error conditions - wrong number of args +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +echo "*** Testing parse_url() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing parse_url() function with Zero arguments --\n"; +var_dump( parse_url() ); + +//Test parse_url with one more than the expected number of arguments +echo "\n-- Testing parse_url() function with more than expected no. of arguments --\n"; +$url = 'string_val'; +$url_component = 10; +$extra_arg = 10; +var_dump( parse_url($url, $url_component, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing parse_url() : error conditions *** + +-- Testing parse_url() function with Zero arguments -- + +Warning: parse_url() expects at least 1 parameter, 0 given in %s on line 12 +NULL + +-- Testing parse_url() function with more than expected no. of arguments -- + +Warning: parse_url() expects at most 2 parameters, 3 given in %s on line 19 +NULL +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_error_002.phpt b/ext/standard/tests/url/parse_url_error_002.phpt new file mode 100644 index 0000000..45c20f4 --- /dev/null +++ b/ext/standard/tests/url/parse_url_error_002.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test parse_url() function: url component specifier out of range +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +echo "*** Testing parse_url() : error conditions: url component specifier out of range ***\n"; +$url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123'; + +echo "--> Below range:"; +var_dump(parse_url($url, -1)); + +echo "\n\n--> Above range:"; +var_dump(parse_url($url, 99)); + +echo "Done" +?> +--EXPECTF-- +*** Testing parse_url() : error conditions: url component specifier out of range *** +--> Below range:array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + + +--> Above range: +Warning: parse_url(): Invalid URL component identifier 99 in %s on line 15 +bool(false) +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_relative_scheme.phpt b/ext/standard/tests/url/parse_url_relative_scheme.phpt new file mode 100644 index 0000000..7c8952d --- /dev/null +++ b/ext/standard/tests/url/parse_url_relative_scheme.phpt @@ -0,0 +1,11 @@ +--TEST-- +Test parse_url() function: Checks relative URL schemes (e.g. "//example.com") +--FILE-- +<?php +var_dump(parse_url('//example.org')); +--EXPECT-- +array(1) { + ["host"]=> + string(11) "example.org" +} + diff --git a/ext/standard/tests/url/parse_url_variation_001.phpt b/ext/standard/tests/url/parse_url_variation_001.phpt new file mode 100644 index 0000000..0b804ee --- /dev/null +++ b/ext/standard/tests/url/parse_url_variation_001.phpt @@ -0,0 +1,226 @@ +--TEST-- +Test parse_url() function : usage variations - unexpected type for arg 1. +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing parse_url() : usage variations ***\n"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for url + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( parse_url($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing parse_url() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(60) +Error: 8 - Undefined variable: unset_var, %s(63) + +Arg value 0 +array(1) { + ["path"]=> + string(1) "0" +} + +Arg value 1 +array(1) { + ["path"]=> + string(1) "1" +} + +Arg value 12345 +array(1) { + ["path"]=> + string(5) "12345" +} + +Arg value -2345 +array(1) { + ["path"]=> + string(5) "-2345" +} + +Arg value 10.5 +array(1) { + ["path"]=> + string(4) "10.5" +} + +Arg value -10.5 +array(1) { + ["path"]=> + string(5) "-10.5" +} + +Arg value 101234567000 +array(1) { + ["path"]=> + string(12) "101234567000" +} + +Arg value 1.07654321E-9 +array(1) { + ["path"]=> + string(13) "1.07654321E-9" +} + +Arg value 0.5 +array(1) { + ["path"]=> + string(3) "0.5" +} +Error: 8 - Array to string conversion, %sparse_url_variation_001.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_001.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_001.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_001.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_001.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 1 to be string, array given, %s(70) +NULL + +Arg value +array(1) { + ["path"]=> + string(0) "" +} + +Arg value +array(1) { + ["path"]=> + string(0) "" +} + +Arg value 1 +array(1) { + ["path"]=> + string(1) "1" +} + +Arg value +array(1) { + ["path"]=> + string(0) "" +} + +Arg value 1 +array(1) { + ["path"]=> + string(1) "1" +} + +Arg value +array(1) { + ["path"]=> + string(0) "" +} + +Arg value +array(1) { + ["path"]=> + string(0) "" +} + +Arg value +array(1) { + ["path"]=> + string(0) "" +} +Error: 4096 - Object of class stdClass could not be converted to string, %s(69) + +Arg value +Error: 2 - parse_url() expects parameter 1 to be string, object given, %s(70) +NULL + +Arg value +array(1) { + ["path"]=> + string(0) "" +} + +Arg value +array(1) { + ["path"]=> + string(0) "" +} +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_variation_002_32bit.phpt b/ext/standard/tests/url/parse_url_variation_002_32bit.phpt new file mode 100644 index 0000000..aefb37a --- /dev/null +++ b/ext/standard/tests/url/parse_url_variation_002_32bit.phpt @@ -0,0 +1,205 @@ +--TEST-- +Test parse_url() function : usage variations - unexpected type for arg 2. +--SKIPIF-- +<?php if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only"); ?> +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing parse_url() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for url_component + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( parse_url($url, $value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing parse_url() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(61) +Error: 8 - Undefined variable: unset_var, %s(64) + +Arg value 10.5 +Error: 2 - parse_url(): Invalid URL component identifier 10, %s(71) +bool(false) + +Arg value -10.5 +array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +Arg value 101234567000 +array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +Arg value 1.07654321E-9 +string(4) "http" + +Arg value 0.5 +string(4) "http" +Error: 8 - Array to string conversion, %sparse_url_variation_002_32bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_32bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_32bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_32bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_32bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL + +Arg value +string(4) "http" + +Arg value +string(4) "http" + +Arg value 1 +string(11) "www.php.net" + +Arg value +string(4) "http" + +Arg value 1 +string(11) "www.php.net" + +Arg value +string(4) "http" + +Arg value +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL + +Arg value +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL + +Arg value string +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL + +Arg value string +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL +Error: 4096 - Object of class stdClass could not be converted to string, %s(70) + +Arg value +Error: 2 - parse_url() expects parameter 2 to be long, object given, %s(71) +NULL + +Arg value +string(4) "http" + +Arg value +string(4) "http" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/parse_url_variation_002_64bit.phpt b/ext/standard/tests/url/parse_url_variation_002_64bit.phpt new file mode 100644 index 0000000..35a600c --- /dev/null +++ b/ext/standard/tests/url/parse_url_variation_002_64bit.phpt @@ -0,0 +1,189 @@ +--TEST-- +Test parse_url() function : usage variations - unexpected type for arg 2. +--SKIPIF-- +<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); ?> +--FILE-- +<?php +/* Prototype : proto mixed parse_url(string url, [int url_component]) + * Description: Parse a URL and return its components + * Source code: ext/standard/url.c + * Alias to functions: + */ + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing parse_url() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$url = 'http://secret:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for url_component + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( parse_url($url, $value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing parse_url() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(61) +Error: 8 - Undefined variable: unset_var, %s(64) + +Arg value 10.5 +Error: 2 - parse_url(): Invalid URL component identifier 10, %s(71) +bool(false) + +Arg value -10.5 +array(8) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "www.php.net" + ["port"]=> + int(80) + ["user"]=> + string(6) "secret" + ["pass"]=> + string(7) "hideout" + ["path"]=> + string(10) "/index.php" + ["query"]=> + string(31) "test=1&test2=char&test3=mixesCI" + ["fragment"]=> + string(16) "some_page_ref123" +} + +Arg value 101234567000 +Error: 2 - parse_url(): Invalid URL component identifier %d, %s(71) +bool(false) + +Arg value 1.07654321E-9 +string(4) "http" + +Arg value 0.5 +string(4) "http" +Error: 8 - Array to string conversion, %sparse_url_variation_002_64bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_64bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_64bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_64bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL +Error: 8 - Array to string conversion, %sparse_url_variation_002_64bit.php(%d) + +Arg value Array +Error: 2 - parse_url() expects parameter 2 to be long, array given, %s(71) +NULL + +Arg value +string(4) "http" + +Arg value +string(4) "http" + +Arg value 1 +string(11) "www.php.net" + +Arg value +string(4) "http" + +Arg value 1 +string(11) "www.php.net" + +Arg value +string(4) "http" + +Arg value +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL + +Arg value +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL + +Arg value string +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL + +Arg value string +Error: 2 - parse_url() expects parameter 2 to be long, string given, %s(71) +NULL +Error: 4096 - Object of class stdClass could not be converted to string, %s(70) + +Arg value +Error: 2 - parse_url() expects parameter 2 to be long, object given, %s(71) +NULL + +Arg value +string(4) "http" + +Arg value +string(4) "http" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/rawurldecode_error_001.phpt b/ext/standard/tests/url/rawurldecode_error_001.phpt new file mode 100644 index 0000000..1dcaf40 --- /dev/null +++ b/ext/standard/tests/url/rawurldecode_error_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test rawurldecode() function : error conditions - wrong number of args +--FILE-- +<?php +/* Prototype : proto string rawurldecode(string str) + * Description: Decodes URL-encodes string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +echo "*** Testing rawurldecode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing rawurldecode() function with Zero arguments --\n"; +var_dump( rawurldecode() ); + +//Test rawurldecode with one more than the expected number of arguments +echo "\n-- Testing rawurldecode() function with more than expected no. of arguments --\n"; +$str = 'string_val'; +$extra_arg = 10; +var_dump( rawurldecode($str, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing rawurldecode() : error conditions *** + +-- Testing rawurldecode() function with Zero arguments -- + +Warning: rawurldecode() expects exactly 1 parameter, 0 given in %s on line 14 +NULL + +-- Testing rawurldecode() function with more than expected no. of arguments -- + +Warning: rawurldecode() expects exactly 1 parameter, 2 given in %s on line 20 +NULL +Done diff --git a/ext/standard/tests/url/rawurldecode_variation_001.phpt b/ext/standard/tests/url/rawurldecode_variation_001.phpt new file mode 100644 index 0000000..9527fe6 --- /dev/null +++ b/ext/standard/tests/url/rawurldecode_variation_001.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test rawurldecode() function : usage variations - unexpected type for arg 1. +--FILE-- +<?php +/* Prototype : proto string rawurldecode(string str) + * Description: Decodes URL-encodes string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing rawurldecode() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for str + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( rawurldecode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing rawurldecode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(64) +Error: 8 - Undefined variable: unset_var, %s(67) + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" +Error: 8 - Array to string conversion, %srawurldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" +Error: 4096 - Object of class stdClass could not be converted to string, %s(73) + +Arg value +Error: 2 - rawurldecode() expects parameter 1 to be string, object given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/rawurlencode_error_001.phpt b/ext/standard/tests/url/rawurlencode_error_001.phpt new file mode 100644 index 0000000..7acce9e --- /dev/null +++ b/ext/standard/tests/url/rawurlencode_error_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test rawurlencode() function : error conditions +--FILE-- +<?php +/* Prototype : proto string rawurlencode(string str) + * Description: URL-encodes string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +echo "*** Testing rawurlencode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing rawurlencode() function with Zero arguments --\n"; +var_dump( rawurlencode() ); + +//Test rawurlencode with one more than the expected number of arguments +echo "\n-- Testing rawurlencode() function with more than expected no. of arguments --\n"; +$str = 'string_val'; +$extra_arg = 10; +var_dump( rawurlencode($str, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing rawurlencode() : error conditions *** + +-- Testing rawurlencode() function with Zero arguments -- + +Warning: rawurlencode() expects exactly 1 parameter, 0 given in %s on line 14 +NULL + +-- Testing rawurlencode() function with more than expected no. of arguments -- + +Warning: rawurlencode() expects exactly 1 parameter, 2 given in %s on line 20 +NULL +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/rawurlencode_variation_001.phpt b/ext/standard/tests/url/rawurlencode_variation_001.phpt new file mode 100644 index 0000000..a344336 --- /dev/null +++ b/ext/standard/tests/url/rawurlencode_variation_001.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test rawurlencode() function : usage variations - unexpected type for arg 1. +--FILE-- +<?php +/* Prototype : proto string rawurlencode(string str) + * Description: URL-encodes string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing rawurlencode() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for str + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( rawurlencode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing rawurlencode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(64) +Error: 8 - Undefined variable: unset_var, %s(67) + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" +Error: 8 - Array to string conversion, %srawurlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %srawurlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - rawurlencode() expects parameter 1 to be string, array given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" +Error: 4096 - Object of class stdClass could not be converted to string, %s(73) + +Arg value +Error: 2 - rawurlencode() expects parameter 1 to be string, object given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/urldecode_error_001.phpt b/ext/standard/tests/url/urldecode_error_001.phpt new file mode 100644 index 0000000..f0e5ae0 --- /dev/null +++ b/ext/standard/tests/url/urldecode_error_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test urldecode() function : error conditions +--FILE-- +<?php +/* Prototype : proto string urldecode(string str) + * Description: Decodes URL-encoded string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +echo "*** Testing urldecode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing urldecode() function with Zero arguments --\n"; +var_dump( urldecode() ); + +//Test urldecode with one more than the expected number of arguments +echo "\n-- Testing urldecode() function with more than expected no. of arguments --\n"; +$str = 'string_val'; +$extra_arg = 10; +var_dump( urldecode($str, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing urldecode() : error conditions *** + +-- Testing urldecode() function with Zero arguments -- + +Warning: urldecode() expects exactly 1 parameter, 0 given in %s on line 14 +NULL + +-- Testing urldecode() function with more than expected no. of arguments -- + +Warning: urldecode() expects exactly 1 parameter, 2 given in %s on line 20 +NULL +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/urldecode_variation_001.phpt b/ext/standard/tests/url/urldecode_variation_001.phpt new file mode 100644 index 0000000..42026d1 --- /dev/null +++ b/ext/standard/tests/url/urldecode_variation_001.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test urldecode() function : usage variations - <type here specifics of this variation> +--FILE-- +<?php +/* Prototype : proto string urldecode(string str) + * Description: Decodes URL-encoded string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing urldecode() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for str + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( urldecode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing urldecode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(64) +Error: 8 - Undefined variable: unset_var, %s(67) + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" +Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surldecode_variation_001.php(%d) + +Arg value Array +Error: 2 - urldecode() expects parameter 1 to be string, array given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" +Error: 4096 - Object of class stdClass could not be converted to string, %s(73) + +Arg value +Error: 2 - urldecode() expects parameter 1 to be string, object given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/urlencode_error_001.phpt b/ext/standard/tests/url/urlencode_error_001.phpt new file mode 100644 index 0000000..fc00b05 --- /dev/null +++ b/ext/standard/tests/url/urlencode_error_001.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test urlencode() function : error conditions +--FILE-- +<?php +/* Prototype : proto string urlencode(string str) + * Description: URL-encodes string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +echo "*** Testing urlencode() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing urlencode() function with Zero arguments --\n"; +var_dump( urlencode() ); + +//Test urlencode with one more than the expected number of arguments +echo "\n-- Testing urlencode() function with more than expected no. of arguments --\n"; +$str = 'string_val'; +$extra_arg = 10; +var_dump( urlencode($str, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing urlencode() : error conditions *** + +-- Testing urlencode() function with Zero arguments -- + +Warning: urlencode() expects exactly 1 parameter, 0 given in %s on line 14 +NULL + +-- Testing urlencode() function with more than expected no. of arguments -- + +Warning: urlencode() expects exactly 1 parameter, 2 given in %s on line 20 +NULL +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/urlencode_variation_001.phpt b/ext/standard/tests/url/urlencode_variation_001.phpt new file mode 100644 index 0000000..04d0921 --- /dev/null +++ b/ext/standard/tests/url/urlencode_variation_001.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test urlencode() function : usage variations - <type here specifics of this variation> +--FILE-- +<?php +/* Prototype : proto string urlencode(string str) + * Description: URL-encodes string + * Source code: ext/standard/url.c + * Alias to functions: + */ + +// NB: basic functionality tested in tests/strings/001.phpt + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; +} +set_error_handler('test_error_handler'); + +echo "*** Testing urlencode() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new stdclass(), + + // undefined data + $undefined_var, + + // unset data + $unset_var, +); + +// loop through each element of the array for str + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( urlencode($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing urlencode() : usage variations *** +Error: 8 - Undefined variable: undefined_var, %s(64) +Error: 8 - Undefined variable: unset_var, %s(67) + +Arg value 0 +string(1) "0" + +Arg value 1 +string(1) "1" + +Arg value 12345 +string(5) "12345" + +Arg value -2345 +string(5) "-2345" + +Arg value 10.5 +string(4) "10.5" + +Arg value -10.5 +string(5) "-10.5" + +Arg value 101234567000 +string(12) "101234567000" + +Arg value 1.07654321E-9 +string(13) "1.07654321E-9" + +Arg value 0.5 +string(3) "0.5" +Error: 8 - Array to string conversion, %surlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74) +NULL +Error: 8 - Array to string conversion, %surlencode_variation_001.php(%d) + +Arg value Array +Error: 2 - urlencode() expects parameter 1 to be string, array given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value 1 +string(1) "1" + +Arg value +string(0) "" + +Arg value +string(0) "" + +Arg value +string(0) "" +Error: 4096 - Object of class stdClass could not be converted to string, %s(73) + +Arg value +Error: 2 - urlencode() expects parameter 1 to be string, object given, %s(74) +NULL + +Arg value +string(0) "" + +Arg value +string(0) "" +Done
\ No newline at end of file diff --git a/ext/standard/tests/url/urls.inc b/ext/standard/tests/url/urls.inc new file mode 100644 index 0000000..27521c8 --- /dev/null +++ b/ext/standard/tests/url/urls.inc @@ -0,0 +1,109 @@ +<?php +$urls = array( +// Parsable URLs: +'64.246.30.37', +'http://64.246.30.37', +'http://64.246.30.37/', +'64.246.30.37/', +'64.246.30.37:80/', +'php.net', +'php.net/', +'http://php.net', +'http://php.net/', +'www.php.net', +'www.php.net/', +'http://www.php.net', +'http://www.php.net/', +'www.php.net:80', +'http://www.php.net:80', +'http://www.php.net:80/', +'http://www.php.net/index.php', +'www.php.net/?', +'www.php.net:80/?', +'http://www.php.net/?', +'http://www.php.net:80/?', +'http://www.php.net:80/index.php', +'http://www.php.net:80/foo/bar/index.php', +'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php', +'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2¶meters=3&too=4&here=5', +'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/', +'http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php', +'http://www.php.net:80/this/../a/../deep/directory', +'http://www.php.net:80/this/../a/../deep/directory/', +'http://www.php.net:80/this/is/a/very/deep/directory/../file.php', +'http://www.php.net:80/index.php', +'http://www.php.net:80/index.php?', +'http://www.php.net:80/#foo', +'http://www.php.net:80/?#', +'http://www.php.net:80/?test=1', +'http://www.php.net/?test=1&', +'http://www.php.net:80/?&', +'http://www.php.net:80/index.php?test=1&', +'http://www.php.net/index.php?&', +'http://www.php.net:80/index.php?foo&', +'http://www.php.net/index.php?&foo', +'http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI', +'www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123', +'nntp://news.php.net', +'ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz', +'zlib:http://foo@bar', +'zlib:filename.txt', +'zlib:/path/to/my/file/file.txt', +'foo://foo@bar', +'mailto:me@mydomain.com', +'/foo.php?a=b&c=d', +'foo.php?a=b&c=d', +'http://user:passwd@www.example.com:8080?bar=1&boom=0', +'file:///path/to/file', +'file://path/to/file', +'file:/path/to/file', +'http://1.2.3.4:/abc.asp?a=1&b=2', +'http://foo.com#bar', +'scheme:', +'foo+bar://baz@bang/bla', +'gg:9130731', +'http://user:@pass@host/path?argument?value#etc', +'http://10.10.10.10/:80', +'http://x:?', +'x:blah.com', +'x:/blah.com', +'x://::abc/?', +'http://::?', +'x://::6.5', +'http://?:/', +'http://@?:/', +'file:///:', +'file:///a:/', +'file:///ab:/', +'file:///a:/', +'file:///@:/', +'file:///:80/', +'[]', +'http://[x:80]/', +'', +'/', + +// Severely malformed URLs that do not parse: +'http:///blah.com', +'http://:80', +'http://user@:80', +'http://user:pass@:80', +'http://:', +'http://@/', +'http://@:/', +'http://:/', +'http://?', +'http://?:', +'http://:?', +'http://blah.com:123456', +'http://blah.com:abcdef', +); + + +?>
\ No newline at end of file |