diff options
Diffstat (limited to 'ext/standard/tests/general_functions')
23 files changed, 767 insertions, 0 deletions
diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt new file mode 100644 index 0000000000..68495a13d9 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation2.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with boolean values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt new file mode 100644 index 0000000000..d1fb5e7dda --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation3.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with emptyUnsetUndefNull values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt new file mode 100644 index 0000000000..8dac4f8a40 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation4.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with float values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt new file mode 100644 index 0000000000..392abb32c5 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with int values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt new file mode 100644 index 0000000000..3b5b08c6d5 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation7.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with string values. +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +session.use_cookies=0 +session.serialize_handler=php +session.save_handler=files +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with unknown string values ***\n"; + + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with unknown string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_basic.phpt b/ext/standard/tests/general_functions/getservbyname_basic.phpt new file mode 100755 index 0000000000..164e71afd4 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + $services = array('http', 'ftp', 'ssh', 'telnet', 'imap', 'smtp', 'nicname', 'gopher', 'finger', 'pop3', 'www'); + + foreach ($services as $service) { + $port = getservbyname($service, 'tcp'); + var_dump($port); + } + + +?> +--EXPECTF-- +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) +int(%d) diff --git a/ext/standard/tests/general_functions/getservbyname_variation10.phpt b/ext/standard/tests/general_functions/getservbyname_variation10.phpt new file mode 100755 index 0000000000..70aa567646 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation10.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with emptyUnsetUndefNull values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with emptyUnsetUndefNull values ***\n"; + +$service = "www"; + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation11.phpt b/ext/standard/tests/general_functions/getservbyname_variation11.phpt new file mode 100755 index 0000000000..3c410c55b6 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation11.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with float values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with float values ***\n"; + +$service = "www"; + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation12.phpt b/ext/standard/tests/general_functions/getservbyname_variation12.phpt new file mode 100755 index 0000000000..7e5323cca8 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation12.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with int values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with int values ***\n"; + +$service = "www"; + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation14.phpt b/ext/standard/tests/general_functions/getservbyname_variation14.phpt new file mode 100755 index 0000000000..d93b53ece4 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation14.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with string values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with string values ***\n"; + +$service = "www"; + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation2.phpt b/ext/standard/tests/general_functions/getservbyname_variation2.phpt new file mode 100755 index 0000000000..877c1d12af --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation2.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with boolean values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation3.phpt b/ext/standard/tests/general_functions/getservbyname_variation3.phpt new file mode 100755 index 0000000000..d34259d2a2 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation3.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with emptyUnsetUndefNull values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with emptyUnsetUndefNull values ***\n"; + +$protocol = "tcp"; + + +$unset_var = 10; +unset($unset_var); + +$variation_array = array( + 'unset var' => @$unset_var, + 'undefined var' => @$undefined_var, + 'empty string DQ' => "", + 'empty string SQ' => '', + 'uppercase NULL' => NULL, + 'lowercase null' => null, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation4.phpt b/ext/standard/tests/general_functions/getservbyname_variation4.phpt new file mode 100755 index 0000000000..6033c94363 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation4.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with float values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array( + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation5.phpt b/ext/standard/tests/general_functions/getservbyname_variation5.phpt new file mode 100755 index 0000000000..1d3b8f6d74 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation5.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with int values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + +$protocol = "tcp"; + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation7.phpt b/ext/standard/tests/general_functions/getservbyname_variation7.phpt new file mode 100755 index 0000000000..a0e223c50d --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation7.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with string values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with string values ***\n"; + +$protocol = "tcp"; + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyname_variation9.phpt b/ext/standard/tests/general_functions/getservbyname_variation9.phpt new file mode 100755 index 0000000000..c1c231e148 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation9.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with boolean values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with boolean values ***\n"; + +$service = "www"; + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/standard/tests/general_functions/getservbyport_basic.phpt b/ext/standard/tests/general_functions/getservbyport_basic.phpt new file mode 100644 index 0000000000..c18c0b7731 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyport_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + if(stristr(PHP_OS, "linux")) $file = "/etc/services"; + elseif(stristr(PHP_OS, "Darwin")) $file = "/etc/services"; + elseif(substr(PHP_OS,0,3) == "WIN") $file = "C:/WINDOWS/system32/drivers/etc/services"; + else die(PHP_OS. " unsupported"); + + if(file_exists($file)){ + var_dump(getservbyport( 80, "tcp" ) === "www"); + }else{ + var_dump(getservbyport(80, "tcp") === false); + } +?> +--EXPECTF-- +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_basic.phpt b/ext/standard/tests/general_functions/proc_nice_basic.phpt new file mode 100644 index 0000000000..5a95756276 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +proc_nice() basic behaviour +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + function getNice($id) + { + $res = shell_exec('ps -p ' . $id .' -o "%p %n"'); + preg_match('/^\s*\w+\s+\w+\s*(\d+)\s+(\d+)/m', $res, $matches); + if (count($matches) > 2) + return $matches[2]; + else + return -1; + } + $delta = 10; + $pid = getmypid(); + $niceBefore = getNice($pid); + proc_nice($delta); + $niceAfter = getNice($pid); + var_dump($niceBefore == ($niceAfter - $delta)); +?> +--EXPECTF-- +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_error.phpt b/ext/standard/tests/general_functions/proc_nice_error.phpt new file mode 100644 index 0000000000..c50812c863 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test function proc_nice() by calling it more than or less than its expected arguments +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n" + +$priority = + + +$extra_arg = + +var_dump(proc_nice( $priority, $extra_arg ) ); + +var_dump(proc_nice( ) ); + + +?> +--EXPECTF-- +Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in %s on line %d diff --git a/ext/standard/tests/general_functions/proc_nice_variation1.phpt b/ext/standard/tests/general_functions/proc_nice_variation1.phpt new file mode 100644 index 0000000000..b86155c4b2 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation1.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with array values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with array values ***\n"; + + + +$index_array = array(1, 2, 3); +$assoc_array = array(1 => 'one', 2 => 'two'); + +$variation_array = array( + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, array given in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/proc_nice_variation2.phpt b/ext/standard/tests/general_functions/proc_nice_variation2.phpt new file mode 100644 index 0000000000..620fe91447 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation2.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with boolean values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with boolean values ***\n"; + + + +$variation_array = array( + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/general_functions/proc_nice_variation5.phpt b/ext/standard/tests/general_functions/proc_nice_variation5.phpt new file mode 100644 index 0000000000..d8325106ba --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation5.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with int values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(true) +bool(true) +bool(true) + +Warning: proc_nice(): Only a super user may attempt to increase the priority of a process in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/proc_nice_variation6.phpt b/ext/standard/tests/general_functions/proc_nice_variation6.phpt new file mode 100644 index 0000000000..b4babd5930 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation6.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with object values. +--CREDITS-- +Italian PHP TestFest 2009 Cesena 19-20-21 june +Fabio Fabbrucci (fabbrucci@grupporetina.com) +Michele Orselli (mo@ideato.it) +Simone Gentili (sensorario@gmail.com) +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + + + +function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { + if (error_reporting() != 0) { + // report non-silenced errors + echo "Error: $err_no - $err_msg, $filename($linenum)\n"; + } +} +set_error_handler('test_error_handler'); + + + +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - proc_nice() expects parameter 1 to be long, object given, %s(%d) +bool(false) +Error: 2 - proc_nice() expects parameter 1 to be long, object given, %s(%d) +bool(false) |