diff options
Diffstat (limited to 'tests/basic')
66 files changed, 1892 insertions, 0 deletions
diff --git a/tests/basic/001.phpt b/tests/basic/001.phpt new file mode 100644 index 0000000..d0cc1ca --- /dev/null +++ b/tests/basic/001.phpt @@ -0,0 +1,6 @@ +--TEST-- +Trivial "Hello World" test +--FILE-- +<?php echo "Hello World"?> +--EXPECT-- +Hello World diff --git a/tests/basic/002.phpt b/tests/basic/002.phpt new file mode 100644 index 0000000..25dc513 --- /dev/null +++ b/tests/basic/002.phpt @@ -0,0 +1,9 @@ +--TEST-- +Simple POST Method test +--POST-- +a=Hello+World +--FILE-- +<?php +echo $_POST['a']; ?> +--EXPECT-- +Hello World diff --git a/tests/basic/003.phpt b/tests/basic/003.phpt new file mode 100644 index 0000000..43d3be1 --- /dev/null +++ b/tests/basic/003.phpt @@ -0,0 +1,12 @@ +--TEST-- +GET and POST Method combined +--POST-- +a=Hello+World +--GET-- +b=Hello+Again+World&c=Hi+Mom +--FILE-- +<?php +error_reporting(0); +echo "post-a=({$_POST['a']}) get-b=({$_GET['b']}) get-c=({$_GET['c']})"?> +--EXPECT-- +post-a=(Hello World) get-b=(Hello Again World) get-c=(Hi Mom) diff --git a/tests/basic/004.phpt b/tests/basic/004.phpt new file mode 100644 index 0000000..c381e50 --- /dev/null +++ b/tests/basic/004.phpt @@ -0,0 +1,10 @@ +--TEST-- +Two variables in POST data +--POST-- +a=Hello+World&b=Hello+Again+World +--FILE-- +<?php +error_reporting(0); +echo "{$_POST['a']} {$_POST['b']}" ?> +--EXPECT-- +Hello World Hello Again World diff --git a/tests/basic/005.phpt b/tests/basic/005.phpt new file mode 100644 index 0000000..742e0ca --- /dev/null +++ b/tests/basic/005.phpt @@ -0,0 +1,10 @@ +--TEST-- +Three variables in POST data +--POST-- +a=Hello+World&b=Hello+Again+World&c=1 +--FILE-- +<?php +error_reporting(0); +echo "{$_POST['a']} {$_POST['b']} {$_POST['c']}"?> +--EXPECT-- +Hello World Hello Again World 1 diff --git a/tests/basic/006.phpt b/tests/basic/006.phpt new file mode 100644 index 0000000..c614cd9 --- /dev/null +++ b/tests/basic/006.phpt @@ -0,0 +1,6 @@ +--TEST-- +Add 3 variables together and print result +--FILE-- +<?php $a=1; $b=2; $c=3; $d=$a+$b+$c; echo $d?> +--EXPECT-- +6 diff --git a/tests/basic/007.phpt b/tests/basic/007.phpt new file mode 100644 index 0000000..dc808b7 --- /dev/null +++ b/tests/basic/007.phpt @@ -0,0 +1,6 @@ +--TEST-- +Multiply 3 variables and print result +--FILE-- +<?php $a=2; $b=4; $c=8; $d=$a*$b*$c; echo $d?> +--EXPECT-- +64 diff --git a/tests/basic/008.phpt b/tests/basic/008.phpt new file mode 100644 index 0000000..511aef0 --- /dev/null +++ b/tests/basic/008.phpt @@ -0,0 +1,6 @@ +--TEST-- +Divide 3 variables and print result +--FILE-- +<?php $a=27; $b=3; $c=3; $d=$a/$b/$c; echo $d?> +--EXPECT-- +3 diff --git a/tests/basic/009.phpt b/tests/basic/009.phpt new file mode 100644 index 0000000..fefe529 --- /dev/null +++ b/tests/basic/009.phpt @@ -0,0 +1,6 @@ +--TEST-- +Subtract 3 variables and print result +--FILE-- +<?php $a=27; $b=7; $c=10; $d=$a-$b-$c; echo $d?> +--EXPECT-- +10 diff --git a/tests/basic/010.phpt b/tests/basic/010.phpt new file mode 100644 index 0000000..9cdfece --- /dev/null +++ b/tests/basic/010.phpt @@ -0,0 +1,6 @@ +--TEST-- +Testing | and & operators +--FILE-- +<?php $a=8; $b=4; $c=8; echo $a|$b&$c?> +--EXPECT-- +8 diff --git a/tests/basic/011.phpt b/tests/basic/011.phpt new file mode 100644 index 0000000..7925674 --- /dev/null +++ b/tests/basic/011.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing $argc and $argv handling (GET) +--INI-- +register_argc_argv=1 +--GET-- +ab+cd+ef+123+test +--FILE-- +<?php +$argc = $_SERVER['argc']; +$argv = $_SERVER['argv']; + +for ($i=0; $i<$argc; $i++) { + echo "$i: ".$argv[$i]."\n"; +} + +?> +--EXPECT-- +0: ab +1: cd +2: ef +3: 123 +4: test diff --git a/tests/basic/012.phpt b/tests/basic/012.phpt new file mode 100644 index 0000000..5c10c7c --- /dev/null +++ b/tests/basic/012.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing $argc and $argv handling (cli) +--SKIPIF-- +<?php if(php_sapi_name()!='cli') echo 'skip'; ?> +--INI-- +register_argc_argv=1 +variables_order=GPS +--ARGS-- +ab cd ef 123 test +--FILE-- +<?php +$argc = $_SERVER['argc']; +$argv = $_SERVER['argv']; + +for ($i=1; $i<$argc; $i++) { + echo ($i-1).": ".$argv[$i]."\n"; +} + +?> +--EXPECT-- +0: ab +1: cd +2: ef +3: 123 +4: test diff --git a/tests/basic/013.phpt b/tests/basic/013.phpt new file mode 100644 index 0000000..376cc06 --- /dev/null +++ b/tests/basic/013.phpt @@ -0,0 +1,13 @@ +--TEST-- +POST Method test and arrays +--POST-- +a[]=1 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(1) { + [0]=> + string(1) "1" +} diff --git a/tests/basic/014.phpt b/tests/basic/014.phpt new file mode 100644 index 0000000..7288c44 --- /dev/null +++ b/tests/basic/014.phpt @@ -0,0 +1,15 @@ +--TEST-- +POST Method test and arrays - 2 +--POST-- +a[]=1&a[]=1 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" +} diff --git a/tests/basic/015.phpt b/tests/basic/015.phpt new file mode 100644 index 0000000..eecbaf1 --- /dev/null +++ b/tests/basic/015.phpt @@ -0,0 +1,13 @@ +--TEST-- +POST Method test and arrays - 3 +--POST-- +a[]=1&a[0]=5 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(1) { + [0]=> + string(1) "5" +} diff --git a/tests/basic/016.phpt b/tests/basic/016.phpt new file mode 100644 index 0000000..b34fd1b --- /dev/null +++ b/tests/basic/016.phpt @@ -0,0 +1,15 @@ +--TEST-- +POST Method test and arrays - 4 +--POST-- +a[a]=1&a[b]=3 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(2) { + ["a"]=> + string(1) "1" + ["b"]=> + string(1) "3" +} diff --git a/tests/basic/017.phpt b/tests/basic/017.phpt new file mode 100644 index 0000000..d514726 --- /dev/null +++ b/tests/basic/017.phpt @@ -0,0 +1,17 @@ +--TEST-- +POST Method test and arrays - 5 +--POST-- +a[]=1&a[a]=1&a[b]=3 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(3) { + [0]=> + string(1) "1" + ["a"]=> + string(1) "1" + ["b"]=> + string(1) "3" +} diff --git a/tests/basic/018.phpt b/tests/basic/018.phpt new file mode 100644 index 0000000..45996b2 --- /dev/null +++ b/tests/basic/018.phpt @@ -0,0 +1,34 @@ +--TEST-- +POST Method test and arrays - 6 +--POST-- +a[][]=1&a[][]=3&b[a][b][c]=1&b[a][b][d]=1 +--FILE-- +<?php +var_dump($_POST['a']); +var_dump($_POST['b']); +?> +--EXPECT-- +array(2) { + [0]=> + array(1) { + [0]=> + string(1) "1" + } + [1]=> + array(1) { + [0]=> + string(1) "3" + } +} +array(1) { + ["a"]=> + array(1) { + ["b"]=> + array(2) { + ["c"]=> + string(1) "1" + ["d"]=> + string(1) "1" + } + } +} diff --git a/tests/basic/019.phpt b/tests/basic/019.phpt new file mode 100644 index 0000000..3bece24 --- /dev/null +++ b/tests/basic/019.phpt @@ -0,0 +1,17 @@ +--TEST-- +POST Method test and arrays - 7 +--POST-- +a[]=1&a[]]=3&a[[]=4 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "3" + ["["]=> + string(1) "4" +} diff --git a/tests/basic/020.phpt b/tests/basic/020.phpt new file mode 100644 index 0000000..c94a604 --- /dev/null +++ b/tests/basic/020.phpt @@ -0,0 +1,15 @@ +--TEST-- +POST Method test and arrays - 8 +--POST-- +a[a[]]=1&a[b[]]=3 +--FILE-- +<?php +var_dump($_POST['a']); +?> +--EXPECT-- +array(2) { + ["a["]=> + string(1) "1" + ["b["]=> + string(1) "3" +} diff --git a/tests/basic/021.phpt b/tests/basic/021.phpt new file mode 100644 index 0000000..eeaf588 --- /dev/null +++ b/tests/basic/021.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #37276 (problems witch $_POST array) +--INI-- +file_uploads=1 +upload_tmp_dir=. +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="submitter" + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="pics"; filename="bug37276.txt" +Content-Type: text/plain + +bug37276 + +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(1) { + ["pics"]=> + array(5) { + ["name"]=> + string(12) "bug37276.txt" + ["type"]=> + string(10) "text/plain" + ["tmp_name"]=> + string(%d) "%s" + ["error"]=> + int(0) + ["size"]=> + int(9) + } +} +array(1) { + ["submitter"]=> + string(8) "testname" +} diff --git a/tests/basic/022.phpt b/tests/basic/022.phpt new file mode 100644 index 0000000..0ab70d4 --- /dev/null +++ b/tests/basic/022.phpt @@ -0,0 +1,34 @@ +--TEST-- +Cookies test#1 +--INI-- +max_input_vars=1000 +filter.default=unsafe_raw +--COOKIE-- +cookie1=val1 ; cookie2=val2%20; cookie3=val 3.; cookie 4= value 4 %3B; cookie1=bogus; %20cookie1=ignore;+cookie1=ignore;cookie1;cookie 5=%20 value; cookie%206=þæö;cookie+7=;$cookie.8;cookie-9=1;;;- & % $cookie 10=10 +--FILE-- +<?php +var_dump($_COOKIE); +?> +--EXPECT-- +array(10) { + ["cookie1"]=> + string(6) "val1 " + ["cookie2"]=> + string(5) "val2 " + ["cookie3"]=> + string(6) "val 3." + ["cookie_4"]=> + string(10) " value 4 ;" + ["cookie__5"]=> + string(7) " value" + ["cookie_6"]=> + string(3) "þæö" + ["cookie_7"]=> + string(0) "" + ["$cookie_8"]=> + string(0) "" + ["cookie-9"]=> + string(1) "1" + ["-_&_%_$cookie_10"]=> + string(2) "10" +} diff --git a/tests/basic/023.phpt b/tests/basic/023.phpt new file mode 100644 index 0000000..ca5f1dc --- /dev/null +++ b/tests/basic/023.phpt @@ -0,0 +1,20 @@ +--TEST-- +Cookies test#2 +--INI-- +max_input_vars=1000 +filter.default=unsafe_raw +--COOKIE-- +c o o k i e=value; c o o k i e= v a l u e ;;c%20o+o k+i%20e=v;name="value","value",UEhQIQ==;UEhQIQ==foo +--FILE-- +<?php +var_dump($_COOKIE); +?> +--EXPECT-- +array(3) { + ["c_o_o_k_i_e"]=> + string(5) "value" + ["name"]=> + string(24) ""value","value",UEhQIQ==" + ["UEhQIQ"]=> + string(4) "=foo" +} diff --git a/tests/basic/024.phpt b/tests/basic/024.phpt new file mode 100644 index 0000000..bf8a206 --- /dev/null +++ b/tests/basic/024.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test HTTP_RAW_POST_DATA creation +--INI-- +always_populate_raw_post_data=1 +max_input_vars=1000 +--POST-- +a=ABC&y=XYZ&c[]=1&c[]=2&c[a]=3 +--FILE-- +<?php +var_dump($_POST, $HTTP_RAW_POST_DATA); +?> +--EXPECT-- +array(3) { + ["a"]=> + string(3) "ABC" + ["y"]=> + string(3) "XYZ" + ["c"]=> + array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + ["a"]=> + string(1) "3" + } +} +string(30) "a=ABC&y=XYZ&c[]=1&c[]=2&c[a]=3" diff --git a/tests/basic/025.phpt b/tests/basic/025.phpt new file mode 100644 index 0000000..58191bc --- /dev/null +++ b/tests/basic/025.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test HTTP_RAW_POST_DATA with excessive post length +--INI-- +always_populate_raw_post_data=1 +post_max_size=1K +--POST-- +a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +--FILE-- +<?php +var_dump($_POST, $HTTP_RAW_POST_DATA); +?> +--EXPECTF-- +Warning: Unknown: POST Content-Length of 2050 bytes exceeds the limit of 1024 bytes in Unknown on line 0 + +Warning: Cannot modify header information - headers already sent in Unknown on line 0 + +Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d +array(0) { +} +NULL diff --git a/tests/basic/026.phpt b/tests/basic/026.phpt new file mode 100644 index 0000000..b98a31f --- /dev/null +++ b/tests/basic/026.phpt @@ -0,0 +1,15 @@ +--TEST-- +Registration of HTTP_RAW_POST_DATA due to unknown content-type +--INI-- +always_populate_raw_post_data=0 +--POST_RAW-- +Content-Type: unknown/type +a=1&b=ZYX +--FILE-- +<?php +var_dump($_POST, $HTTP_RAW_POST_DATA); +?> +--EXPECT-- +array(0) { +} +string(9) "a=1&b=ZYX" diff --git a/tests/basic/027.phpt b/tests/basic/027.phpt new file mode 100644 index 0000000..0528e83 --- /dev/null +++ b/tests/basic/027.phpt @@ -0,0 +1,33 @@ +--TEST-- +Handling of max_input_nesting_level being reached +--INI-- +always_populate_raw_post_data=0 +display_errors=0 +max_input_nesting_level=10 +max_input_vars=1000 +track_errors=1 +log_errors=0 +--POST-- +a=1&b=ZYX&c[][][][][][][][][][][][][][][][][][][][][][]=123&d=123&e[][]][]=3 +--FILE-- +<?php +var_dump($_POST, $php_errormsg); +?> +--EXPECT-- +array(4) { + ["a"]=> + string(1) "1" + ["b"]=> + string(3) "ZYX" + ["d"]=> + string(3) "123" + ["e"]=> + array(1) { + [0]=> + array(1) { + [0]=> + string(1) "3" + } + } +} +string(115) "Unknown: Input variable nesting level exceeded 10. To increase the limit change max_input_nesting_level in php.ini." diff --git a/tests/basic/028.phpt b/tests/basic/028.phpt new file mode 100644 index 0000000..37d6f21 --- /dev/null +++ b/tests/basic/028.phpt @@ -0,0 +1,105 @@ +--TEST-- +RFC1867 character quotting +--INI-- +file_uploads=1 +max_input_vars=1000 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name=name1 + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name='name2' + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="name3" + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name=name\4 + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name=name\\5 + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name=name\'6 + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name=name\"7 + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name='name\8' + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name='name\\9' + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name='name\'10' + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name='name\"11' + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="name\12" + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="name\\13" + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="name\'14" + +testname +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="name\"15" + +testname +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_POST); +?> +--EXPECT-- +array(15) { + ["name1"]=> + string(8) "testname" + ["name2"]=> + string(8) "testname" + ["name3"]=> + string(8) "testname" + ["name\4"]=> + string(8) "testname" + ["name\5"]=> + string(8) "testname" + ["name\'6"]=> + string(8) "testname" + ["name\"7"]=> + string(8) "testname" + ["name\8"]=> + string(8) "testname" + ["name\9"]=> + string(8) "testname" + ["name'10"]=> + string(8) "testname" + ["name\"11"]=> + string(8) "testname" + ["name\12"]=> + string(8) "testname" + ["name\13"]=> + string(8) "testname" + ["name\'14"]=> + string(8) "testname" + ["name"15"]=> + string(8) "testname" +} diff --git a/tests/basic/029.phpt b/tests/basic/029.phpt new file mode 100644 index 0000000..6d95c07 --- /dev/null +++ b/tests/basic/029.phpt @@ -0,0 +1,51 @@ +--TEST-- +Shift_JIS request +--SKIPIF-- +<?php +if (!extension_loaded("mbstring")) { + die("skip Requires mbstring extension"); +} +?> +--INI-- +file_uploads=1 +mbstring.encoding_translation=1 +mbstring.http_input=Shift_JIS +mbstring.internal_encoding=UTF-8 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="—\Ž\”\" + +ƒhƒŒƒ~ƒtƒ@ƒ\ +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="pics"; filename="file1.txt" +Content-Type: text/plain + +file1 + +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(1) { + ["pics"]=> + array(5) { + ["name"]=> + string(9) "file1.txt" + ["type"]=> + string(10) "text/plain" + ["tmp_name"]=> + string(%d) "%s" + ["error"]=> + int(0) + ["size"]=> + int(6) + } +} +array(1) { + ["予蚕能"]=> + string(18) "ドレミファソ" +} diff --git a/tests/basic/030.phpt b/tests/basic/030.phpt new file mode 100644 index 0000000..cf2a270 --- /dev/null +++ b/tests/basic/030.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug#55504 (Content-Type header is not parsed correctly on HTTP POST request) +--INI-- +file_uploads=1 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=BVoyv; charset=iso-8859-1 +--BVoyv +Content-Disposition: form-data; name="data" + +abc +--BVoyv-- +--FILE-- +<?php +var_dump($_POST); +?> +--EXPECT-- +array(1) { + ["data"]=> + string(3) "abc" +} diff --git a/tests/basic/031.phpt b/tests/basic/031.phpt new file mode 100644 index 0000000..12b8354 --- /dev/null +++ b/tests/basic/031.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug#55504 (Content-Type header is not parsed correctly on HTTP POST request) +--INI-- +file_uploads=1 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=BVoyv; charset=iso-8859-1 +--BVoyv +Content-Disposition: form-data; name="data" + +abc +--BVoyv +Content-Disposition: form-data; name="data2" + +more data +--BVoyv +Content-Disposition: form-data; name="data3" + +even more data +--BVoyv-- +--FILE-- +<?php +var_dump($_POST); +?> +--EXPECT-- +array(3) { + ["data"]=> + string(3) "abc" + ["data2"]=> + string(9) "more data" + ["data3"]=> + string(14) "even more data" +} diff --git a/tests/basic/032.phpt b/tests/basic/032.phpt new file mode 100644 index 0000000..a6aba5b --- /dev/null +++ b/tests/basic/032.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug#18792 (no form variables after multipart/form-data) +--INI-- +file_uploads=1 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=BVoyv, charset=iso-8859-1 +--BVoyv +Content-Disposition: form-data; name="data" + +abc +--BVoyv-- +--FILE-- +<?php +var_dump($_POST); +?> +--EXPECT-- +array(1) { + ["data"]=> + string(3) "abc" +} diff --git a/tests/basic/bug20539.phpt b/tests/basic/bug20539.phpt new file mode 100644 index 0000000..1406ce0 --- /dev/null +++ b/tests/basic/bug20539.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #20539 (PHP CLI Segmentation Fault) +--SKIPIF-- +<?php if (!extension_loaded("session")) die("skip session extension not available"); ?> +<?php unlink(__DIR__. '/sess_' .session_id()); ?> +--INI-- +session.auto_start=1 +session.save_handler=files +session.save_path=./tests/basic/ +--FILE-- +<?php + print "good :)\n"; + $filename = __DIR__ . '/sess_' . session_id(); + var_dump(file_exists($filename)); + @unlink($filename); +?> +--EXPECT-- +good :) +bool(true) + diff --git a/tests/basic/bug29971.phpt b/tests/basic/bug29971.phpt new file mode 100644 index 0000000..d4b654b --- /dev/null +++ b/tests/basic/bug29971.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #29971 (variables_order behaviour) +--INI-- +variables_order=GPC +--FILE-- +<?php +var_dump($_ENV,$_SERVER); +var_dump(ini_get("variables_order")); +?> +--EXPECT-- +array(0) { +} +array(0) { +} +string(3) "GPC" diff --git a/tests/basic/bug45986.phpt b/tests/basic/bug45986.phpt new file mode 100644 index 0000000..1c30f10 --- /dev/null +++ b/tests/basic/bug45986.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #45986 (wrong error message for a non existant file on rename) +--CREDITS-- +Sebastian Schürmann +sebs@php.net +Testfest 2009 Munich +--FILE-- +<?php +rename('foo', 'bar'); +?> +--EXPECTF-- +Warning: %s in %sbug45986.php on line 2 diff --git a/tests/basic/bug51709_1.phpt b/tests/basic/bug51709_1.phpt new file mode 100644 index 0000000..3f2d544 --- /dev/null +++ b/tests/basic/bug51709_1.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #51709 (Can't use keywords as method names) +--FILE-- +<?php + +class foo { + static function for() { + echo "1"; + } +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Parse error: syntax error, unexpected %s, expecting %s in %sbug51709_1.php on line %d diff --git a/tests/basic/bug51709_2.phpt b/tests/basic/bug51709_2.phpt new file mode 100644 index 0000000..bb1f91c --- /dev/null +++ b/tests/basic/bug51709_2.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #51709 (Can't use keywords as method names) +--FILE-- +<?php + +class foo { + static function goto() { + echo "1"; + } +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Parse error: syntax error, unexpected %s, expecting %s in %sbug51709_2.php on line %d diff --git a/tests/basic/bug53180.phpt b/tests/basic/bug53180.phpt new file mode 100644 index 0000000..5c2eb76 --- /dev/null +++ b/tests/basic/bug53180.phpt @@ -0,0 +1,19 @@ +--TEST--
+Bug #53180 (post_max_size=0 partly not working)
+--INI--
+post_max_size=0
+--POST--
+email=foo&password=bar&submit=Log+on
+--FILE--
+<?php
+var_dump($_POST);
+?>
+--EXPECT--
+array(3) {
+ ["email"]=>
+ string(3) "foo"
+ ["password"]=>
+ string(3) "bar"
+ ["submit"]=>
+ string(6) "Log on"
+}
diff --git a/tests/basic/bug54514.phpt b/tests/basic/bug54514.phpt new file mode 100644 index 0000000..0c5595e --- /dev/null +++ b/tests/basic/bug54514.phpt @@ -0,0 +1,12 @@ +--TEST-- +Req #54514 (Get php binary path during script execution) +--FILE-- +<?php +if(realpath(getenv('TEST_PHP_EXECUTABLE')) === realpath(PHP_BINARY)) { + echo "done"; +} else { + var_dump(getenv('TEST_PHP_EXECUTABLE')); + var_dump(PHP_BINARY); +} +--EXPECT-- +done diff --git a/tests/basic/bug55500.phpt b/tests/basic/bug55500.phpt new file mode 100644 index 0000000..97eeea2 --- /dev/null +++ b/tests/basic/bug55500.phpt @@ -0,0 +1,68 @@ +--TEST-- +Bug #55500 (Corrupted $_FILES indices lead to security concern) +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +upload_max_filesize=1024 +max_file_uploads=10 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[]"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[[type]"; filename="file2.txt" +Content-Type: text/plain-file2 + +2 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[[name]"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[name]["; filename="file4.txt" +Content-Type: text/plain-file3 + +4 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(1) { + [%u|b%"file"]=> + array(5) { + [%u|b%"name"]=> + array(1) { + [0]=> + %unicode|string%(9) "file1.txt" + } + [%u|b%"type"]=> + array(1) { + [0]=> + %unicode|string%(16) "text/plain-file1" + } + [%u|b%"tmp_name"]=> + array(1) { + [0]=> + %unicode|string%(%d) "%s" + } + [%u|b%"error"]=> + array(1) { + [0]=> + int(0) + } + [%u|b%"size"]=> + array(1) { + [0]=> + int(1) + } + } +} +array(0) { +} diff --git a/tests/basic/bug61000.phpt b/tests/basic/bug61000.phpt new file mode 100644 index 0000000..8149d68 --- /dev/null +++ b/tests/basic/bug61000.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #61000 (Exceeding max nesting level doesn't delete numerical vars) +--INI-- +max_input_nesting_level=2 +--POST-- +1[a][]=foo&1[a][b][c]=bar +--GET-- +a[a][]=foo&a[a][b][c]=bar +--FILE-- +<?php +print_r($_GET); +print_r($_POST); +--EXPECTF-- +Array +( +) +Array +( +) diff --git a/tests/basic/enable_post_data_reading_01.phpt b/tests/basic/enable_post_data_reading_01.phpt new file mode 100644 index 0000000..1a0e33f --- /dev/null +++ b/tests/basic/enable_post_data_reading_01.phpt @@ -0,0 +1,22 @@ +--TEST-- +enable_post_data_reading: basic test +--INI-- +enable_post_data_reading=0 +--POST_RAW-- +Content-Type: application/x-www-form-urlencoded +a=1&b=ZYX +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +var_dump($HTTP_RAW_POST_DATA); +var_dump(file_get_contents("php://input")); +--EXPECTF-- +array(0) { +} +array(0) { +} + +Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d +NULL +string(9) "a=1&b=ZYX" diff --git a/tests/basic/enable_post_data_reading_02.phpt b/tests/basic/enable_post_data_reading_02.phpt new file mode 100644 index 0000000..dc7f6b1 --- /dev/null +++ b/tests/basic/enable_post_data_reading_02.phpt @@ -0,0 +1,28 @@ +--TEST-- +enable_post_data_reading: rfc1867 +--INI-- +enable_post_data_reading=0 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +var_dump(file_get_contents("php://input")); +--EXPECTF-- +array(0) { +} +array(0) { +} +string(%d) "-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file + +1 +-----------------------------20896060251896012921717172737--" diff --git a/tests/basic/enable_post_data_reading_03.phpt b/tests/basic/enable_post_data_reading_03.phpt new file mode 100644 index 0000000..cdabe91 --- /dev/null +++ b/tests/basic/enable_post_data_reading_03.phpt @@ -0,0 +1,23 @@ +--TEST-- +enable_post_data_reading: always_populate_raw_post_data has no effect (1) +--INI-- +enable_post_data_reading=0 +always_populate_raw_post_data=1 +--POST_RAW-- +Content-Type: application/x-www-form-urlencoded +a=1&b=ZYX +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +var_dump($HTTP_RAW_POST_DATA); +var_dump(file_get_contents("php://input")); +--EXPECTF-- +array(0) { +} +array(0) { +} + +Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d +NULL +string(9) "a=1&b=ZYX" diff --git a/tests/basic/enable_post_data_reading_04.phpt b/tests/basic/enable_post_data_reading_04.phpt new file mode 100644 index 0000000..a168504 --- /dev/null +++ b/tests/basic/enable_post_data_reading_04.phpt @@ -0,0 +1,23 @@ +--TEST-- +enable_post_data_reading: always_populate_raw_post_data has no effect (2) +--INI-- +enable_post_data_reading=0 +always_populate_raw_post_data=1 +--POST_RAW-- +Content-Type: application/unknown +a=1&b=ZYX +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +var_dump($HTTP_RAW_POST_DATA); +var_dump(file_get_contents("php://input")); +--EXPECTF-- +array(0) { +} +array(0) { +} + +Notice: Undefined variable: HTTP_RAW_POST_DATA in %s on line %d +NULL +string(9) "a=1&b=ZYX" diff --git a/tests/basic/php_egg_logo_guid.phpt b/tests/basic/php_egg_logo_guid.phpt new file mode 100644 index 0000000..b3c5d7b --- /dev/null +++ b/tests/basic/php_egg_logo_guid.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing php_egg_logo_guid() function +--FILE-- +<?php +echo php_egg_logo_guid(); +?> +--EXPECT-- +PHPE9568F36-D428-11d2-A769-00AA001ACF42 + +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/basic/php_logo_guid.phpt b/tests/basic/php_logo_guid.phpt new file mode 100644 index 0000000..b5724a9 --- /dev/null +++ b/tests/basic/php_logo_guid.phpt @@ -0,0 +1,10 @@ +--TEST-- +Testing php_logo_guid() function +--FILE-- +<?php +echo php_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 +--CREDITS-- +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/basic/php_real_logo_guid.phpt b/tests/basic/php_real_logo_guid.phpt new file mode 100644 index 0000000..2b9003a --- /dev/null +++ b/tests/basic/php_real_logo_guid.phpt @@ -0,0 +1,12 @@ +--TEST-- +Testing php_real_logo_guid() function +--FILE-- +<?php +echo php_real_logo_guid(); +?> +--EXPECT-- +PHPE9568F34-D428-11d2-A769-00AA001ACF42 +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20
\ No newline at end of file diff --git a/tests/basic/req44164.phpt b/tests/basic/req44164.phpt new file mode 100644 index 0000000..d008286 --- /dev/null +++ b/tests/basic/req44164.phpt @@ -0,0 +1,17 @@ +--TEST--
+Req #44164 (Handle "Content-Length" HTTP header when zlib.output_compression active)
+--SKIPIF--
+<?php
+if (!function_exists('gzdeflate'))
+ die("skip zlib extension required");
+?>
+--INI--
+zlib.output_compression=On
+--ENV--
+HTTP_ACCEPT_ENCODING=gzip
+--FILE--
+<?php
+header("Content-length: 200");
+echo str_repeat("a", 200);
+--EXPECT--
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
diff --git a/tests/basic/rfc1867_anonymous_upload.phpt b/tests/basic/rfc1867_anonymous_upload.phpt new file mode 100644 index 0000000..ce1f447 --- /dev/null +++ b/tests/basic/rfc1867_anonymous_upload.phpt @@ -0,0 +1,57 @@ +--TEST-- +rfc1867 anonymous upload +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +max_file_uploads=10 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; filename="file2.txt" +Content-Type: text/plain-file2 + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(2) { + [%d]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%d]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file2" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(0) { +} diff --git a/tests/basic/rfc1867_array_upload.phpt b/tests/basic/rfc1867_array_upload.phpt new file mode 100644 index 0000000..d9f9353 --- /dev/null +++ b/tests/basic/rfc1867_array_upload.phpt @@ -0,0 +1,84 @@ +--TEST-- +rfc1867 array upload +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +max_file_uploads=10 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[]"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[2]"; filename="file2.txt" +Content-Type: text/plain-file2 + +2 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[]"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(1) { + [%u|b%"file"]=> + array(5) { + [%u|b%"name"]=> + array(3) { + [0]=> + %unicode|string%(9) "file1.txt" + [2]=> + %unicode|string%(9) "file2.txt" + [3]=> + %unicode|string%(9) "file3.txt" + } + [%u|b%"type"]=> + array(3) { + [0]=> + %unicode|string%(16) "text/plain-file1" + [2]=> + %unicode|string%(16) "text/plain-file2" + [3]=> + %unicode|string%(16) "text/plain-file3" + } + [%u|b%"tmp_name"]=> + array(3) { + [0]=> + %unicode|string%(%d) "%s" + [2]=> + %unicode|string%(%d) "%s" + [3]=> + %unicode|string%(%d) "%s" + } + [%u|b%"error"]=> + array(3) { + [0]=> + int(0) + [2]=> + int(0) + [3]=> + int(0) + } + [%u|b%"size"]=> + array(3) { + [0]=> + int(1) + [2]=> + int(1) + [3]=> + int(1) + } + } +} +array(0) { +} diff --git a/tests/basic/rfc1867_boundary_1.phpt b/tests/basic/rfc1867_boundary_1.phpt new file mode 100644 index 0000000..fe0a9f2 --- /dev/null +++ b/tests/basic/rfc1867_boundary_1.phpt @@ -0,0 +1,25 @@ +--TEST-- +rfc1867 boundary 1 +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--POST_RAW-- +Content-Type: multipart/form-data; boundary="------------------------------------foobar" +--------------------------------------foobar +Content-Disposition: form-data; name="foobar" + +1 +--------------------------------------foobar-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(0) { +} +array(1) { + [%u|b%"foobar"]=> + %unicode|string%(1) "1" +} diff --git a/tests/basic/rfc1867_boundary_2.phpt b/tests/basic/rfc1867_boundary_2.phpt new file mode 100644 index 0000000..256ec4b --- /dev/null +++ b/tests/basic/rfc1867_boundary_2.phpt @@ -0,0 +1,25 @@ +--TEST-- +rfc1867 boundary 2 +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--POST_RAW-- +Content-Type: multipart/form-data; boundary=------------------------------------foo, bar +--------------------------------------foo +Content-Disposition: form-data; name="foobar" + +1 +--------------------------------------foo-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(0) { +} +array(1) { + [%u|b%"foobar"]=> + %unicode|string%(1) "1" +} diff --git a/tests/basic/rfc1867_empty_upload.phpt b/tests/basic/rfc1867_empty_upload.phpt new file mode 100644 index 0000000..c2dcb9b --- /dev/null +++ b/tests/basic/rfc1867_empty_upload.phpt @@ -0,0 +1,89 @@ +--TEST-- +rfc1867 empty upload +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +max_file_uploads=10 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foo" + + +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="" +Content-Type: text/plain-file2 + + +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file3"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +if (is_uploaded_file($_FILES["file1"]["tmp_name"])) { + var_dump(file_get_contents($_FILES["file1"]["tmp_name"])); +} +if (is_uploaded_file($_FILES["file3"]["tmp_name"])) { + var_dump(file_get_contents($_FILES["file3"]["tmp_name"])); +} +?> +--EXPECTF-- +array(3) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(0) "" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(4) + [%u|b%"size"]=> + int(0) + } + [%u|b%"file3"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file3.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file3" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(1) { + [%u|b%"foo"]=> + %unicode|string%(0) "" +} +string(1) "1" +string(1) "3" diff --git a/tests/basic/rfc1867_file_upload_disabled.phpt b/tests/basic/rfc1867_file_upload_disabled.phpt new file mode 100644 index 0000000..99dee9b --- /dev/null +++ b/tests/basic/rfc1867_file_upload_disabled.phpt @@ -0,0 +1,36 @@ +--TEST-- +rfc1867 file_upload disabled +--INI-- +file_uploads=0 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foo" + +bar +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="bar" + +foo +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(0) { +} +array(2) { + [%u|b%"foo"]=> + %unicode|string%(3) "bar" + [%u|b%"bar"]=> + %unicode|string%(3) "foo" +} diff --git a/tests/basic/rfc1867_garbled_mime_headers.phpt b/tests/basic/rfc1867_garbled_mime_headers.phpt new file mode 100644 index 0000000..4010f22 --- /dev/null +++ b/tests/basic/rfc1867_garbled_mime_headers.phpt @@ -0,0 +1,25 @@ +--TEST-- +rfc1867 garbled mime headers +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data + + +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +Warning: File Upload Mime headers garbled in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_invalid_boundary.phpt b/tests/basic/rfc1867_invalid_boundary.phpt new file mode 100644 index 0000000..cb27675 --- /dev/null +++ b/tests/basic/rfc1867_invalid_boundary.phpt @@ -0,0 +1,24 @@ +--TEST-- +rfc1867 invalid boundary +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--POST_RAW-- +Content-Type: multipart/form-data; boundary="foobar +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foobar" + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +Warning: Invalid boundary in multipart/form-data POST data in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_malicious_input.phpt b/tests/basic/rfc1867_malicious_input.phpt new file mode 100644 index 0000000..40b43d2 --- /dev/null +++ b/tests/basic/rfc1867_malicious_input.phpt @@ -0,0 +1,25 @@ +--TEST-- +rfc1867 malicious input +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foo[]bar"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_max_file_size.phpt b/tests/basic/rfc1867_max_file_size.phpt new file mode 100644 index 0000000..9c576b4 --- /dev/null +++ b/tests/basic/rfc1867_max_file_size.phpt @@ -0,0 +1,89 @@ +--TEST-- +rfc1867 MAX_FILE_SIZE +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +max_file_uploads=10 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="MAX_FILE_SIZE" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" +Content-Type: text/plain-file2 + +22 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file3"; filename="C:\foo\bar/file3.txt" +Content-Type: text/plain-file3; + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +if (is_uploaded_file($_FILES["file1"]["tmp_name"])) { + var_dump(file_get_contents($_FILES["file1"]["tmp_name"])); +} +if (is_uploaded_file($_FILES["file3"]["tmp_name"])) { + var_dump(file_get_contents($_FILES["file3"]["tmp_name"])); +} +?> +--EXPECTF-- +array(3) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(2) + [%u|b%"size"]=> + int(0) + } + [%u|b%"file3"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file3.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file3" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(1) { + [%u|b%"MAX_FILE_SIZE"]=> + %string|unicode%(1) "1" +} +string(1) "1" +string(1) "3" diff --git a/tests/basic/rfc1867_max_file_uploads_empty_files.phpt b/tests/basic/rfc1867_max_file_uploads_empty_files.phpt new file mode 100644 index 0000000..76327fd --- /dev/null +++ b/tests/basic/rfc1867_max_file_uploads_empty_files.phpt @@ -0,0 +1,101 @@ +--TEST--
+rfc1867 max_file_uploads - empty files shouldn't count (non-debug version)
+--SKIPIF--
+<?php if(function_exists("leak")) print "skip only for non-debug builds"; ?>
+--INI--
+file_uploads=1
+error_reporting=E_ALL
+max_file_uploads=2
+--POST_RAW--
+Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file2"; filename=""
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file3"; filename=""
+Content-Type: text/plain-file
+
+33
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file4"; filename="file4.txt"
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain-file
+
+1
+-----------------------------20896060251896012921717172737--
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+if (is_uploaded_file($_FILES["file1"]["tmp_name"])) {
+ var_dump(file_get_contents($_FILES["file1"]["tmp_name"]));
+}
+if (is_uploaded_file($_FILES["file4"]["tmp_name"])) {
+ var_dump(file_get_contents($_FILES["file4"]["tmp_name"]));
+}
+?>
+--EXPECTF--
+array(4) {
+ ["file2"]=>
+ array(5) {
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ string(0) ""
+ ["tmp_name"]=>
+ string(0) ""
+ ["error"]=>
+ int(4)
+ ["size"]=>
+ int(0)
+ }
+ ["file3"]=>
+ array(5) {
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ string(0) ""
+ ["tmp_name"]=>
+ string(0) ""
+ ["error"]=>
+ int(4)
+ ["size"]=>
+ int(0)
+ }
+ ["file4"]=>
+ array(5) {
+ ["name"]=>
+ string(9) "file4.txt"
+ ["type"]=>
+ string(15) "text/plain-file"
+ ["tmp_name"]=>
+ string(%d) "%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(0)
+ }
+ ["file1"]=>
+ array(5) {
+ ["name"]=>
+ string(9) "file1.txt"
+ ["type"]=>
+ string(15) "text/plain-file"
+ ["tmp_name"]=>
+ string(%d) "%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(1)
+ }
+}
+array(0) {
+}
+string(1) "1"
+string(0) ""
diff --git a/tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt b/tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt new file mode 100644 index 0000000..279851c --- /dev/null +++ b/tests/basic/rfc1867_max_file_uploads_empty_files_debug.phpt @@ -0,0 +1,102 @@ +--TEST--
+rfc1867 max_file_uploads - empty files shouldn't count (debug version)
+--SKIPIF--
+<?php if(!function_exists("leak")) print "skip only for debug builds"; ?>
+--INI--
+file_uploads=1
+error_reporting=E_ALL
+max_file_uploads=1
+--POST_RAW--
+Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file2"; filename=""
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file3"; filename=""
+Content-Type: text/plain-file
+
+33
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file4"; filename="file4.txt"
+Content-Type: text/plain-file
+
+
+-----------------------------20896060251896012921717172737
+Content-Disposition: form-data; name="file1"; filename="file1.txt"
+Content-Type: text/plain-file
+
+1
+-----------------------------20896060251896012921717172737--
+--FILE--
+<?php
+var_dump($_FILES);
+var_dump($_POST);
+if (is_uploaded_file($_FILES["file1"]["tmp_name"])) {
+ var_dump(file_get_contents($_FILES["file1"]["tmp_name"]));
+}
+?>
+--EXPECTF--
+Notice: No file uploaded in Unknown on line 0
+
+Notice: No file uploaded in Unknown on line 0
+
+Warning: Uploaded file size 0 - file [file4=file4.txt] not saved in Unknown on line 0
+array(4) {
+ ["file2"]=>
+ array(5) {
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ string(0) ""
+ ["tmp_name"]=>
+ string(0) ""
+ ["error"]=>
+ int(4)
+ ["size"]=>
+ int(0)
+ }
+ ["file3"]=>
+ array(5) {
+ ["name"]=>
+ string(0) ""
+ ["type"]=>
+ string(0) ""
+ ["tmp_name"]=>
+ string(0) ""
+ ["error"]=>
+ int(4)
+ ["size"]=>
+ int(0)
+ }
+ ["file4"]=>
+ array(5) {
+ ["name"]=>
+ string(9) "file4.txt"
+ ["type"]=>
+ string(0) ""
+ ["tmp_name"]=>
+ string(0) ""
+ ["error"]=>
+ int(5)
+ ["size"]=>
+ int(0)
+ }
+ ["file1"]=>
+ array(5) {
+ ["name"]=>
+ string(9) "file1.txt"
+ ["type"]=>
+ string(15) "text/plain-file"
+ ["tmp_name"]=>
+ string(%d) "%s"
+ ["error"]=>
+ int(0)
+ ["size"]=>
+ int(1)
+ }
+}
+array(0) {
+}
+string(1) "1"
diff --git a/tests/basic/rfc1867_missing_boundary.phpt b/tests/basic/rfc1867_missing_boundary.phpt new file mode 100644 index 0000000..6218b13 --- /dev/null +++ b/tests/basic/rfc1867_missing_boundary.phpt @@ -0,0 +1,24 @@ +--TEST-- +rfc1867 missing boundary +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--POST_RAW-- +Content-Type: multipart/form-data +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foobar" + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +Warning: Missing boundary in multipart/form-data POST data in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_missing_boundary_2.phpt b/tests/basic/rfc1867_missing_boundary_2.phpt new file mode 100644 index 0000000..a8f38ae --- /dev/null +++ b/tests/basic/rfc1867_missing_boundary_2.phpt @@ -0,0 +1,37 @@ +--TEST-- +rfc1867 missing boundary 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +array(1) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(3) + [%u|b%"size"]=> + int(0) + } +} +array(0) { +} diff --git a/tests/basic/rfc1867_post_max_filesize.phpt b/tests/basic/rfc1867_post_max_filesize.phpt new file mode 100644 index 0000000..04c0c5c --- /dev/null +++ b/tests/basic/rfc1867_post_max_filesize.phpt @@ -0,0 +1,83 @@ +--TEST-- +rfc1867 post_max_filesize +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1 +max_file_uploads=10 +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" +Content-Type: text/plain-file2 + +22 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file3"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +if (is_uploaded_file($_FILES["file1"]["tmp_name"])) { + var_dump(file_get_contents($_FILES["file1"]["tmp_name"])); +} +if (is_uploaded_file($_FILES["file3"]["tmp_name"])) { + var_dump(file_get_contents($_FILES["file3"]["tmp_name"])); +} +?> +--EXPECTF-- +array(3) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(1) + [%u|b%"size"]=> + int(0) + } + [%u|b%"file3"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file3.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file3" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(0) { +} +string(1) "1" +string(1) "3" diff --git a/tests/basic/rfc1867_post_max_size.phpt b/tests/basic/rfc1867_post_max_size.phpt new file mode 100644 index 0000000..9228135 --- /dev/null +++ b/tests/basic/rfc1867_post_max_size.phpt @@ -0,0 +1,24 @@ +--TEST-- +rfc1867 post_max_size +--INI-- +post_max_size=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foobar" + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +var_dump($_FILES); +var_dump($_POST); +?> +--EXPECTF-- +Warning: POST Content-Length of %d bytes exceeds the limit of 1 bytes in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/zend_logo_guid.phpt b/tests/basic/zend_logo_guid.phpt new file mode 100644 index 0000000..23ca016 --- /dev/null +++ b/tests/basic/zend_logo_guid.phpt @@ -0,0 +1,13 @@ +--TEST-- +Testing zend_logo_guid() function +--FILE-- +<?php +echo zend_logo_guid(); +?> +--EXPECT-- +PHPE9568F35-D428-11d2-A769-00AA001ACF42 + +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20
\ No newline at end of file |