diff options
Diffstat (limited to 'ext/standard/tests/general_functions')
24 files changed, 1473 insertions, 5 deletions
diff --git a/ext/standard/tests/general_functions/001.phpt b/ext/standard/tests/general_functions/001.phpt index 164bd7fb2..bfd82e55b 100644 --- a/ext/standard/tests/general_functions/001.phpt +++ b/ext/standard/tests/general_functions/001.phpt @@ -61,7 +61,7 @@ sprintf octal binary test: passed sprintf float test: passed 99.00 99.00 -1.23400e-18 -1.23400e+18 -9.84324e+6 --9.84324e+6 +1.234000e-18 +1.234000e+18 +9.843243e+6 +-9.843243e+6 diff --git a/ext/standard/tests/general_functions/bug27678.phpt b/ext/standard/tests/general_functions/bug27678.phpt index ec9cf93cf..5db5890a1 100644 --- a/ext/standard/tests/general_functions/bug27678.phpt +++ b/ext/standard/tests/general_functions/bug27678.phpt @@ -1,5 +1,5 @@ --TEST-- -bug #27678 (number_format() crashes with large numbers) +Bug #27678 (number_format() crashes with large numbers) --FILE-- <?php diff --git a/ext/standard/tests/general_functions/bug34794.phpt b/ext/standard/tests/general_functions/bug34794.phpt new file mode 100644 index 000000000..3aacf7e51 --- /dev/null +++ b/ext/standard/tests/general_functions/bug34794.phpt @@ -0,0 +1,34 @@ +--TEST-- +bug #34794: proc_close() hangs when used with two processes +--SKIPIF-- +<?php +if (!is_executable('/bin/cat')) echo 'skip cat not found'; +?> +--FILE-- +<?php +echo "Opening process 1\n"; +$process1 = proc_open('/bin/cat', array(0 => array('pipe', 'r'), 1 =>array('pipe', 'r')), $pipes1); + +echo "Opening process 2\n"; +$process2 = proc_open('/bin/cat', array(0 => array('pipe', 'r'), 1 =>array('pipe', 'r')), $pipes2); + + +echo "Closing process 1\n"; +fclose($pipes1[0]); +fclose($pipes1[1]); +proc_close($process1); + +echo "Closing process 2\n"; +fclose($pipes2[0]); +fclose($pipes2[1]); +proc_close($process2); + +echo "Done\n"; + +?> +--EXPECTF-- +Opening process 1 +Opening process 2 +Closing process 1 +Closing process 2 +Done diff --git a/ext/standard/tests/general_functions/bug39322.phpt b/ext/standard/tests/general_functions/bug39322.phpt new file mode 100644 index 000000000..cb3459995 --- /dev/null +++ b/ext/standard/tests/general_functions/bug39322.phpt @@ -0,0 +1,44 @@ +--TEST-- +bug #39322: proc_terminate() loosing process resource +--SKIPIF-- +<?php +if (!is_executable('/bin/sleep')) echo 'skip sleep not found'; +?> +--FILE-- +<?php +$descriptors = array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w')); + +$pipes = array(); + +$process = proc_open('/bin/sleep 120', $descriptors, $pipes); + +proc_terminate($process); +sleep(1); // wait a bit to let the process finish +var_dump(proc_get_status($process)); + +echo "Done!\n"; + +?> +--EXPECTF-- +array(8) { + ["command"]=> + string(14) "/bin/sleep 120" + ["pid"]=> + int(%d) + ["running"]=> + bool(false) + ["signaled"]=> + bool(true) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(15) + ["stopsig"]=> + int(0) +} +Done! diff --git a/ext/standard/tests/general_functions/bug40398.phpt b/ext/standard/tests/general_functions/bug40398.phpt new file mode 100755 index 000000000..ab3cc2a2b --- /dev/null +++ b/ext/standard/tests/general_functions/bug40398.phpt @@ -0,0 +1,90 @@ +--TEST-- +Bug #40398 (parent and self callback functions erroneously called statically) +--FILE-- +<?php + +class Base +{ + function __construct($msg) + { + echo __METHOD__ . "($msg)\n"; + } +} + +class Derived_1 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array($this, 'Base::__construct'), $args); + } +} + +class Derived_2 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array($this, 'parent::__construct'), $args); + } +} + +class Derived_3 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array('Base::__construct', $args); + } +} + +class Derived_4 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array('parent::__construct', $args); + } +} + +class Derived_5 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array('Base', '__construct'), $args); + } +} + +class Derived_6 extends Base +{ + public function __construct() + { + $args = func_get_args(); + call_user_func_array(array('parent', '__construct'), $args); + } +} + +new Derived_1('1'); +new Derived_2('2'); +new Derived_3('3'); +new Derived_4('4'); +new Derived_5('5'); +new Derived_6('6'); + +?> +===DONE=== +--EXPECTF-- +Base::__construct(1) +Base::__construct(2) + +Warning: call_user_func_array(): First argument is expected to be a valid callback, 'Base::__construct' was given in %sbug40398.php on line %d + +Warning: call_user_func_array(): First argument is expected to be a valid callback, 'parent::__construct' was given in %sbug40398.php on line %d + +Strict Standards: Non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_5 in %sbug40398.php on line %d +Base::__construct(5) + +Strict Standards: Non-static method Base::__construct() cannot be called statically, assuming $this from compatible context Derived_6 in %sbug40398.php on line %d +Base::__construct(6) +===DONE=== diff --git a/ext/standard/tests/general_functions/bug40752.phpt b/ext/standard/tests/general_functions/bug40752.phpt new file mode 100644 index 000000000..30ed8a4aa --- /dev/null +++ b/ext/standard/tests/general_functions/bug40752.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #40752 (parse_ini_file() segfaults when a scalar setting is redeclared as an array) +--FILE-- +<?php + +$file = dirname(__FILE__)."/bug40752.ini"; +file_put_contents($file, ' +foo = 1; +foo[] = 1; +'); + +var_dump(parse_ini_file($file)); + +file_put_contents($file, ' +foo[] = 1; +foo = 1; +'); + +var_dump(parse_ini_file($file)); + +unlink($file); + +echo "Done\n"; +?> +--EXPECTF-- +array(1) { + ["foo"]=> + array(1) { + [0]=> + string(1) "1" + } +} +array(1) { + ["foo"]=> + string(1) "1" +} +Done diff --git a/ext/standard/tests/general_functions/bug41037.phpt b/ext/standard/tests/general_functions/bug41037.phpt new file mode 100644 index 000000000..eab2c334c --- /dev/null +++ b/ext/standard/tests/general_functions/bug41037.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #41037 (unregister_tick_function() inside the tick function crash PHP) +--FILE-- +<?php + +function a() { + echo "hello"; + unregister_tick_function('a'); +} + +declare (ticks=1); +register_tick_function('a'); + +echo "Done\n"; +?> +--EXPECTF-- +hello +Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d +Done +hello +Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d +hello +Warning: unregister_tick_function(): Unable to delete tick function executed at the moment in %s on line %d diff --git a/ext/standard/tests/general_functions/error_get_last.phpt b/ext/standard/tests/general_functions/error_get_last.phpt new file mode 100644 index 000000000..3ce1339d1 --- /dev/null +++ b/ext/standard/tests/general_functions/error_get_last.phpt @@ -0,0 +1,43 @@ +--TEST-- +error_get_last() tests +--FILE-- +<?php + +var_dump(error_get_last()); +var_dump(error_get_last(true)); +var_dump(error_get_last()); + +$a = $b; + +var_dump(error_get_last()); + +echo "Done\n"; +?> +--EXPECTF-- +NULL + +Warning: Wrong parameter count for error_get_last() in %s on line %d +NULL +array(4) { + ["type"]=> + int(2) + ["message"]=> + string(42) "Wrong parameter count for error_get_last()" + ["file"]=> + string(%d) "%s" + ["line"]=> + int(%d) +} + +Notice: Undefined variable: b in %s on line %d +array(4) { + ["type"]=> + int(8) + ["message"]=> + string(21) "Undefined variable: b" + ["file"]=> + string(%d) "%s" + ["line"]=> + int(%d) +} +Done diff --git a/ext/standard/tests/general_functions/getrusage.phpt b/ext/standard/tests/general_functions/getrusage.phpt new file mode 100644 index 000000000..55abbac37 --- /dev/null +++ b/ext/standard/tests/general_functions/getrusage.phpt @@ -0,0 +1,23 @@ +--TEST-- +getrusage() tests +--SKIPIF-- +<?php if (!function_exists("getrusage")) print "skip"; ?> +--FILE-- +<?php + +var_dump(gettype(getrusage())); +var_dump(gettype(getrusage(1))); +var_dump(gettype(getrusage(-1))); +var_dump(getrusage(array())); + + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "array" +string(5) "array" +string(5) "array" + +Warning: getrusage() expects parameter 1 to be long, array given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/general_functions/head.phpt b/ext/standard/tests/general_functions/head.phpt new file mode 100644 index 000000000..e83bbf6ac --- /dev/null +++ b/ext/standard/tests/general_functions/head.phpt @@ -0,0 +1,53 @@ +--TEST-- +header() and friends +--SKIPIF-- +<?php +if (php_sapi_name() != "cli") { + die("skip this test is for CLI"); +} +?> +--FILE-- +<?php + +$v1 = headers_sent(); +$v2 = headers_list(); +var_dump(header("HTTP 1.0", true, 200)); + +var_dump($v1); +var_dump($v2); + +var_dump(header("")); +var_dump(header("", true)); +var_dump(headers_sent()); +var_dump(headers_list()); +var_dump(header("HTTP blah")); +var_dump(header("HTTP blah", true)); +var_dump(headers_sent()); +var_dump(headers_list()); + +echo "Done\n"; +?> +--EXPECTF-- +NULL +bool(false) +array(0) { +} + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL +bool(true) +array(0) { +} + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL + +Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d +NULL +bool(true) +array(0) { +} +Done diff --git a/ext/standard/tests/general_functions/highlight_heredoc.phpt b/ext/standard/tests/general_functions/highlight_heredoc.phpt index 58f83806a..ee4e2e828 100644 --- a/ext/standard/tests/general_functions/highlight_heredoc.phpt +++ b/ext/standard/tests/general_functions/highlight_heredoc.phpt @@ -1,5 +1,7 @@ --TEST-- highlight_string() handling of heredoc +--INI-- +highlight.html=#000000 --FILE-- <?php $str = ' diff --git a/ext/standard/tests/general_functions/import_request.phpt b/ext/standard/tests/general_functions/import_request.phpt new file mode 100644 index 000000000..23dc049db --- /dev/null +++ b/ext/standard/tests/general_functions/import_request.phpt @@ -0,0 +1,78 @@ +--TEST-- +import_request_variables() tests +--GET-- +a=1&b=heh&c=3&d[]=5&GLOBALS=test&1=hm +--POST-- +ap=25&bp=test&cp=blah3&dp[]=ar +--FILE-- +<?php + +var_dump(import_request_variables()); +var_dump(import_request_variables("")); +var_dump(import_request_variables("", "")); + +var_dump(import_request_variables("g", "")); +var_dump($a, $b, $c, $ap); + +var_dump(import_request_variables("g", "g_")); +var_dump($g_a, $g_b, $g_c, $g_ap, $g_1); + +var_dump(import_request_variables("GP", "i_")); +var_dump($i_a, $i_b, $i_c, $i_ap, $i_bp, $i_cp, $i_dp); + +var_dump(import_request_variables("gGg", "r_")); +var_dump($r_a, $r_b, $r_c, $r_ap); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for import_request_variables() in %s on line %d +NULL + +Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d +NULL + +Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d +NULL + +Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d + +Warning: import_request_variables(): Attempted GLOBALS variable overwrite. in %s on line %d + +Warning: import_request_variables(): Numeric key detected - possible security hazard. in %s on line %d +NULL + +Notice: Undefined variable: ap in %s on line %d +string(1) "1" +string(3) "heh" +string(1) "3" +NULL +NULL + +Notice: Undefined variable: g_ap in %s on line %d + +Notice: Undefined variable: g_1 in %s on line %d +string(1) "1" +string(3) "heh" +string(1) "3" +NULL +NULL +NULL +string(1) "1" +string(3) "heh" +string(1) "3" +string(2) "25" +string(4) "test" +string(5) "blah3" +array(1) { + [0]=> + string(2) "ar" +} +NULL + +Notice: Undefined variable: r_ap in %s on line %d +string(1) "1" +string(3) "heh" +string(1) "3" +NULL +Done diff --git a/ext/standard/tests/general_functions/include_path.phpt b/ext/standard/tests/general_functions/include_path.phpt new file mode 100644 index 000000000..12d7c3f22 --- /dev/null +++ b/ext/standard/tests/general_functions/include_path.phpt @@ -0,0 +1,75 @@ +--TEST-- +*_include_path() tests +--INI-- +include_path=. +--FILE-- +<?php + +var_dump(get_include_path()); +var_dump(get_include_path("var")); + +var_dump(restore_include_path()); +var_dump(restore_include_path("")); + + +var_dump(set_include_path()); +var_dump(get_include_path()); +var_dump(set_include_path("var")); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + +var_dump(set_include_path(".:/path/to/dir")); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + +var_dump(set_include_path("")); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + +var_dump(set_include_path(array())); +var_dump(get_include_path()); + +var_dump(restore_include_path()); +var_dump(get_include_path()); + + +echo "Done\n"; +?> +--EXPECTF-- +string(1) "." + +Warning: Wrong parameter count for get_include_path() in %s on line %d +NULL +NULL + +Warning: Wrong parameter count for restore_include_path() in %s on line %d +NULL + +Warning: Wrong parameter count for set_include_path() in %s on line %d +NULL +string(1) "." +string(1) "." +string(3) "var" +NULL +string(1) "." +string(1) "." +string(14) ".:/path/to/dir" +NULL +string(1) "." +string(1) "." +string(1) "." +NULL +string(1) "." + +Notice: Array to string conversion in %s on line %d +string(1) "." +string(5) "Array" +NULL +string(1) "." +Done diff --git a/ext/standard/tests/general_functions/ini_get_all.phpt b/ext/standard/tests/general_functions/ini_get_all.phpt new file mode 100644 index 000000000..6016873fd --- /dev/null +++ b/ext/standard/tests/general_functions/ini_get_all.phpt @@ -0,0 +1,51 @@ +--TEST-- +ini_get_all() tests +--SKIPIF-- +<?php if (!extension_loaded("pcre")) die("skip"); ?> +--FILE-- +<?php + +var_dump(gettype(ini_get_all())); +var_dump(ini_get_all("")); +var_dump(ini_get_all("nosuchextension")); +var_dump(ini_get_all("reflection")); +var_dump(ini_get_all("pcre")); + +var_dump(ini_get_all("", "")); + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "array" + +Warning: ini_get_all(): Unable to find extension '' in %s on line %d +bool(false) + +Warning: ini_get_all(): Unable to find extension 'nosuchextension' in %s on line %d +bool(false) +array(0) { +} +array(2) { + ["pcre.backtrack_limit"]=> + array(3) { + ["global_value"]=> + string(6) "100000" + ["local_value"]=> + string(6) "100000" + ["access"]=> + int(7) + } + ["pcre.recursion_limit"]=> + array(3) { + ["global_value"]=> + string(6) "100000" + ["local_value"]=> + string(6) "100000" + ["access"]=> + int(7) + } +} + +Warning: ini_get_all() expects at most 1 parameter, 2 given in %s on line %d +bool(false) +Done diff --git a/ext/standard/tests/general_functions/parse_ini_file.phpt b/ext/standard/tests/general_functions/parse_ini_file.phpt new file mode 100644 index 000000000..399a224db --- /dev/null +++ b/ext/standard/tests/general_functions/parse_ini_file.phpt @@ -0,0 +1,175 @@ +--TEST-- +parse_ini_file() tests +--FILE-- +<?php + +$filename = dirname(__FILE__)."/parse_ini_file.dat"; + +var_dump(parse_ini_file()); +var_dump(parse_ini_file(1,1,1)); +var_dump(parse_ini_file($filename)); +var_dump(parse_ini_file($filename, true)); + +$ini = " +test = +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +test== +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +test=test= +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +test= \"new +line\" +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +define("TEST_CONST", "test const value"); +$ini = " +test=TEST_CONST +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename)); + +$ini = " +[section] +test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +[section] +test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, false)); + +$ini = " +section.test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +[section] +section.test=hello +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +[section] +1=2 +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +1=2 +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + +$ini = " +test=test2 +test=test3 +test=test4 +"; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + + +@unlink($filename); +echo "Done\n"; +?> +--EXPECTF-- +Warning: Wrong parameter count for parse_ini_file() in %s on line %d +NULL + +Warning: Wrong parameter count for parse_ini_file() in %s on line %d +NULL + +Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d +array(0) { +} + +Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d +array(0) { +} +array(1) { + ["test"]=> + string(0) "" +} + +Warning: Error parsing %sparse_ini_file.dat on line 2 + in %s on line %d +array(1) { + ["test"]=> + string(0) "" +} + +Warning: Error parsing %sparse_ini_file.dat on line 2 + in %s on line %d +array(1) { + ["test"]=> + string(4) "test" +} +array(1) { + ["test"]=> + string(8) "new +line" +} +array(1) { + ["test"]=> + string(16) "test const value" +} +array(1) { + ["section"]=> + array(1) { + ["test"]=> + string(5) "hello" + } +} +array(1) { + ["test"]=> + string(5) "hello" +} +array(1) { + ["section.test"]=> + string(5) "hello" +} +array(1) { + ["section"]=> + array(1) { + ["section.test"]=> + string(5) "hello" + } +} +array(1) { + ["section"]=> + array(1) { + [1]=> + string(1) "2" + } +} +array(1) { + [1]=> + string(1) "2" +} +array(1) { + ["test"]=> + string(5) "test4" +} +Done diff --git a/ext/standard/tests/general_functions/phpcredits.phpt b/ext/standard/tests/general_functions/phpcredits.phpt new file mode 100644 index 000000000..2a8acc9a8 --- /dev/null +++ b/ext/standard/tests/general_functions/phpcredits.phpt @@ -0,0 +1,54 @@ +--TEST-- +phpcredits() +--FILE-- +<?php + +var_dump(phpcredits()); +var_dump(phpcredits(array())); + +echo "--\n"; +var_dump(phpcredits(0)); + +echo "--\n"; +var_dump(phpcredits(CREDITS_GROUP)); + +?> +--EXPECTF-- +PHP Credits + +PHP Group +%s + +Language Design & Concept +%s + +%wPHP %d Authors%w +%s + +%wSAPI Modules%w +%s + +%wModule Authors%w +%s + +%wPHP Documentation%w +%s + +PHP Quality Assurance Team +%s + +PHP Website Team +%s +bool(true) + +Warning: phpcredits() expects parameter 1 to be long, array given in %sphpcredits.php on line 4 +NULL +-- +PHP Credits +bool(true) +-- +PHP Credits + +PHP Group +%s +bool(true) diff --git a/ext/standard/tests/general_functions/phpcredits2.phpt b/ext/standard/tests/general_functions/phpcredits2.phpt new file mode 100644 index 000000000..e3b6e354d --- /dev/null +++ b/ext/standard/tests/general_functions/phpcredits2.phpt @@ -0,0 +1,32 @@ +--TEST-- +phpcredits() CGI +--SKIPIF-- +<?php if (php_sapi_name()=='cli') echo 'skip'; ?> +--POST-- +dummy=x +--FILE-- +<?php + +var_dump(phpcredits()); +var_dump(phpcredits(array())); + +echo "--\n"; +var_dump(phpcredits(0)); + +echo "--\n"; +var_dump(phpcredits(CREDITS_GROUP)); + +?> +--EXPECTF-- +<!DOCTYPE %s>%s</html> +bool(true) + +Warning: phpcredits() expects parameter 1 to be long, array given in %sphpcredits2.php on line 4 +NULL +-- +<h1>PHP Credits</h1> +bool(true) +-- +<h1>PHP Credits</h1> +%sPHP Group%s +bool(true) diff --git a/ext/standard/tests/general_functions/phpinfo.phpt b/ext/standard/tests/general_functions/phpinfo.phpt new file mode 100644 index 000000000..dab7f327c --- /dev/null +++ b/ext/standard/tests/general_functions/phpinfo.phpt @@ -0,0 +1,75 @@ +--TEST-- +phpinfo() +--FILE-- +<?php +var_dump(phpinfo()); + +echo "--\n"; +var_dump(phpinfo(array())); + +echo "--\n"; +var_dump(phpinfo(0)); + +echo "--\n"; +var_dump(phpinfo(INFO_LICENSE)); + +?> +--EXPECTF-- +phpinfo() +PHP Version => %s + +System => %s +Build Date => %s +Configure Command => %s +Server API => Command Line Interface +Virtual Directory Support => %s +Configuration File (php.ini) Path => %s +PHP API => %d +PHP Extension => %d +Zend Extension => %d +Debug Build => %s +Thread Safety => %s +Zend Memory Manager => %s +IPv6 Support => %s +Registered PHP Streams => %s +Registered Stream Socket Transports => %s +Registered Stream Filters => %s + +%s + _______________________________________________________________________ + + +Configuration + +PHP Core + +%s + +Additional Modules + +%s + +Environment + +%s + +PHP Variables + +%s + +PHP License +%s +bool(true) +-- + +Warning: phpinfo() expects parameter 1 to be long, array given in %sphpinfo.php on line 5 +NULL +-- +phpinfo() +bool(true) +-- +phpinfo() + +PHP License +%s +bool(true) diff --git a/ext/standard/tests/general_functions/phpinfo2.phpt b/ext/standard/tests/general_functions/phpinfo2.phpt new file mode 100644 index 000000000..ba9cc28ab --- /dev/null +++ b/ext/standard/tests/general_functions/phpinfo2.phpt @@ -0,0 +1,33 @@ +--TEST-- +phpinfo() CGI +--SKIPIF-- +<?php if (php_sapi_name()=='cli') echo 'skip'; ?> +--POST-- +dummy=x +--FILE-- +<?php +var_dump(phpinfo()); + +echo "--\n"; +var_dump(phpinfo(array())); + +echo "--\n"; +var_dump(phpinfo(0)); + +echo "--\n"; +var_dump(phpinfo(INFO_LICENSE)); + +?> +--EXPECTF-- +<!DOCTYPE %s> +%s</html>bool(true) +-- + +Warning: phpinfo() expects parameter 1 to be long, array given in %sphpinfo2.php on line 5 +NULL +-- +<!DOCTYPE %s> +%s</html>bool(true) +-- +<!DOCTYPE %s> +%s</html>bool(true) diff --git a/ext/standard/tests/general_functions/proc_open02.phpt b/ext/standard/tests/general_functions/proc_open02.phpt new file mode 100644 index 000000000..3cba15e9a --- /dev/null +++ b/ext/standard/tests/general_functions/proc_open02.phpt @@ -0,0 +1,72 @@ +--TEST-- +proc_open +--SKIPIF-- +<?php +if (!is_executable('/bin/sleep')) echo 'skip no sleep'; +if (!is_executable('/usr/bin/nohup')) echo 'skip no nohup'; +?> +--FILE-- +<?php +$ds = array(array('pipe', 'r')); + +$cat = proc_open( + '/usr/bin/nohup /bin/sleep 50', + $ds, + $pipes +); + +sleep(1); // let the OS run the nohup process before sending the signal + +var_dump(proc_terminate($cat, 1)); // send a SIGHUP +sleep(1); +var_dump(proc_get_status($cat)); + +var_dump(proc_terminate($cat)); // now really quit it +sleep(1); +var_dump(proc_get_status($cat)); + +proc_close($cat); + +echo "Done!\n"; + +?> +--EXPECTF-- +bool(true) +array(8) { + ["command"]=> + string(28) "/usr/bin/nohup /bin/sleep 50" + ["pid"]=> + int(%d) + ["running"]=> + bool(true) + ["signaled"]=> + bool(false) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(0) + ["stopsig"]=> + int(0) +} +bool(true) +array(8) { + ["command"]=> + string(28) "/usr/bin/nohup /bin/sleep 50" + ["pid"]=> + int(%d) + ["running"]=> + bool(false) + ["signaled"]=> + bool(true) + ["stopped"]=> + bool(false) + ["exitcode"]=> + int(-1) + ["termsig"]=> + int(15) + ["stopsig"]=> + int(0) +} +Done! diff --git a/ext/standard/tests/general_functions/putenv.phpt b/ext/standard/tests/general_functions/putenv.phpt new file mode 100644 index 000000000..afe1badce --- /dev/null +++ b/ext/standard/tests/general_functions/putenv.phpt @@ -0,0 +1,28 @@ +--TEST-- +putenv() basic tests +--FILE-- +<?php + +$var_name="SUCHVARSHOULDNOTEXIST"; + +var_dump(getenv($var_name)); +var_dump(putenv($var_name."=value")); +var_dump(getenv($var_name)); + +var_dump(putenv($var_name."=")); +var_dump(getenv($var_name)); + +var_dump(putenv($var_name)); +var_dump(getenv($var_name)); + +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +bool(true) +string(5) "value" +bool(true) +string(0) "" +bool(true) +bool(false) +Done diff --git a/ext/standard/tests/general_functions/rand.phpt b/ext/standard/tests/general_functions/rand.phpt new file mode 100644 index 000000000..e75bd6d37 --- /dev/null +++ b/ext/standard/tests/general_functions/rand.phpt @@ -0,0 +1,63 @@ +--TEST-- +rand() and mt_rand() tests +--FILE-- +<?php + +var_dump(mt_rand()); +var_dump(mt_rand(-1)); +var_dump(mt_rand(-1,1)); +var_dump(mt_rand(0,3)); + +var_dump(rand()); +var_dump(rand(-1)); +var_dump(rand(-1,1)); +var_dump(rand(0,3)); + +var_dump(srand()); +var_dump(srand(-1)); +var_dump(srand(array())); + +var_dump(mt_srand()); +var_dump(mt_srand(-1)); +var_dump(mt_srand(array())); + +var_dump(getrandmax()); +var_dump(getrandmax(1)); + +var_dump(mt_getrandmax()); +var_dump(mt_getrandmax(1)); + +echo "Done\n"; +?> +--EXPECTF-- +int(%d) + +Warning: mt_rand() expects exactly 2 parameters, 1 given in %s on line %d +NULL +int(%i) +int(%d) +int(%d) + +Warning: rand() expects exactly 2 parameters, 1 given in %s on line %d +NULL +int(%i) +int(%d) +NULL +NULL + +Warning: srand() expects parameter 1 to be long, array given in %s on line %d +NULL +NULL +NULL + +Warning: mt_srand() expects parameter 1 to be long, array given in %s on line %d +NULL +int(%d) + +Warning: Wrong parameter count for getrandmax() in %s on line %d +NULL +int(%d) + +Warning: Wrong parameter count for mt_getrandmax() in %s on line %d +NULL +Done diff --git a/ext/standard/tests/general_functions/sys_getloadavg.phpt b/ext/standard/tests/general_functions/sys_getloadavg.phpt new file mode 100644 index 000000000..cb3a798db --- /dev/null +++ b/ext/standard/tests/general_functions/sys_getloadavg.phpt @@ -0,0 +1,32 @@ +--TEST-- +sys_getloadavg() tests +--SKIPIF-- +<?php +if (!function_exists("sys_getloadavg")) die("skip"); +?> +--FILE-- +<?php + +var_dump(sys_getloadavg("")); +var_dump(sys_getloadavg()); + +echo "Done\n"; +?> +--EXPECTF-- +array(3) { + [0]=> + float(%f) + [1]=> + float(%f) + [2]=> + float(%f) +} +array(3) { + [0]=> + float(%f) + [1]=> + float(%f) + [2]=> + float(%f) +} +Done diff --git a/ext/standard/tests/general_functions/type.phpt b/ext/standard/tests/general_functions/type.phpt new file mode 100644 index 000000000..98eccbbda --- /dev/null +++ b/ext/standard/tests/general_functions/type.phpt @@ -0,0 +1,351 @@ +--TEST-- +gettype(), settype() and friends +--FILE-- +<?php + +function foo($errno, $errstr, $errfile, $errline) { + var_dump($errstr); +} + +set_error_handler("foo"); + +$fp = fopen(__FILE__, "r"); +fclose($fp); +$fp1 = fopen(__FILE__, "r"); + +$var1 = "another string"; +$var2 = array(2,3,4); + +$array = array( + array(1,2,3), + $var1, + $var2, + 1, + 2.0, + NULL, + false, + "some string", + $fp, + $fp1, + new stdclass, +); + +$types = array( + "null", + "integer", + "double", + "boolean", + "resource", + "array", + "object", + "string" + ); + +foreach ($array as $var) { + var_dump(gettype($var)); +} + +foreach ($types as $type) { + foreach ($array as $var) { + var_dump(settype($var, $type)); + var_dump($var); + } +} + +echo "Done\n"; +?> +--EXPECTF-- +string(5) "array" +string(6) "string" +string(5) "array" +string(7) "integer" +string(6) "double" +string(4) "NULL" +string(7) "boolean" +string(6) "string" +string(12) "unknown type" +string(8) "resource" +string(6) "object" +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +NULL +bool(true) +int(1) +bool(true) +int(0) +bool(true) +int(1) +bool(true) +int(1) +bool(true) +int(2) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +int(0) +bool(true) +int(5) +bool(true) +int(6) +string(54) "Object of class stdClass could not be converted to int" +bool(true) +int(%d) +bool(true) +float(1) +bool(true) +float(0) +bool(true) +float(1) +bool(true) +float(1) +bool(true) +float(2) +bool(true) +float(0) +bool(true) +float(0) +bool(true) +float(0) +bool(true) +float(5) +bool(true) +float(6) +string(57) "Object of class stdClass could not be converted to double" +bool(true) +float(%d) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(false) +bool(true) +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +string(42) "settype(): Cannot convert to resource type" +bool(false) +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +string(42) "settype(): Cannot convert to resource type" +bool(false) +string(14) "another string" +string(42) "settype(): Cannot convert to resource type" +bool(false) +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +string(42) "settype(): Cannot convert to resource type" +bool(false) +int(1) +string(42) "settype(): Cannot convert to resource type" +bool(false) +float(2) +string(42) "settype(): Cannot convert to resource type" +bool(false) +NULL +string(42) "settype(): Cannot convert to resource type" +bool(false) +bool(false) +string(42) "settype(): Cannot convert to resource type" +bool(false) +string(11) "some string" +string(42) "settype(): Cannot convert to resource type" +bool(false) +resource(%d) of type (Unknown) +string(42) "settype(): Cannot convert to resource type" +bool(false) +resource(%d) of type (stream) +string(42) "settype(): Cannot convert to resource type" +bool(false) +object(stdClass)#%d (0) { +} +bool(true) +array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +bool(true) +array(1) { + [0]=> + string(14) "another string" +} +bool(true) +array(3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +bool(true) +array(1) { + [0]=> + int(1) +} +bool(true) +array(1) { + [0]=> + float(2) +} +bool(true) +array(0) { +} +bool(true) +array(1) { + [0]=> + bool(false) +} +bool(true) +array(1) { + [0]=> + string(11) "some string" +} +bool(true) +array(1) { + [0]=> + resource(%d) of type (Unknown) +} +bool(true) +array(1) { + [0]=> + resource(%d) of type (stream) +} +bool(true) +array(0) { +} +bool(true) +object(stdClass)#%d (3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + string(14) "another string" +} +bool(true) +object(stdClass)#%d (3) { + [0]=> + int(2) + [1]=> + int(3) + [2]=> + int(4) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + int(1) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + float(2) +} +bool(true) +object(stdClass)#%d (0) { +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + bool(false) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + string(11) "some string" +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + resource(%d) of type (Unknown) +} +bool(true) +object(stdClass)#%d (1) { + ["scalar"]=> + resource(%d) of type (stream) +} +bool(true) +object(stdClass)#%d (0) { +} +string(26) "Array to string conversion" +bool(true) +string(5) "Array" +bool(true) +string(14) "another string" +string(26) "Array to string conversion" +bool(true) +string(5) "Array" +bool(true) +string(1) "1" +bool(true) +string(1) "2" +bool(true) +string(0) "" +bool(true) +string(0) "" +bool(true) +string(11) "some string" +bool(true) +string(14) "Resource id #%d" +bool(true) +string(14) "Resource id #%d" +string(57) "Object of class stdClass could not be converted to string" +string(45) "Object of class stdClass to string conversion" +bool(true) +string(6) "Object" +Done |
