diff options
Diffstat (limited to 'ext/posix')
34 files changed, 1143 insertions, 0 deletions
diff --git a/ext/posix/tests/posix_ctermid_basic.phpt b/ext/posix/tests/posix_ctermid_basic.phpt new file mode 100644 index 0000000000..d1d46943ba --- /dev/null +++ b/ext/posix/tests/posix_ctermid_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +Test function posix_ctermid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +var_dump( posix_ctermid() ); + +?> +--EXPECTF-- +string(%d) %s diff --git a/ext/posix/tests/posix_errno_basic.phpt b/ext/posix/tests/posix_errno_basic.phpt new file mode 100644 index 0000000000..cd94a97515 --- /dev/null +++ b/ext/posix/tests/posix_errno_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function posix_errno() by calling it with its expected arguments +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +echo "*** Test by calling method or function with its expected arguments ***\n"; + +// test without any error +var_dump(posix_errno()); + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +int(0) diff --git a/ext/posix/tests/posix_errno_variation1.phpt b/ext/posix/tests/posix_errno_variation1.phpt new file mode 100644 index 0000000000..aa9889f7fe --- /dev/null +++ b/ext/posix/tests/posix_errno_variation1.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test function posix_errno() by calling it with with permission error +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +echo "*** Test by calling function with permission error ***\n"; + +posix_setuid(0); +var_dump(posix_errno()); + +?> +--EXPECTF-- +*** Test by calling function with permission error *** +int(1) diff --git a/ext/posix/tests/posix_errno_variation2.phpt b/ext/posix/tests/posix_errno_variation2.phpt new file mode 100644 index 0000000000..f463d78759 --- /dev/null +++ b/ext/posix/tests/posix_errno_variation2.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function posix_errno() by calling it with its expected arguments +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +echo "*** Test by calling function with pid error ***\n"; + +$pid = 10000; + +do { + $pid += 1; + $result = shell_exec("ps -p " . $pid); +} while (strstr($pid, $result)); + +posix_kill($pid, SIGKILL); +var_dump(posix_errno()); + +?> +--EXPECTF-- +*** Test by calling function with pid error *** +int(3) diff --git a/ext/posix/tests/posix_geteuid_basic.phpt b/ext/posix/tests/posix_geteuid_basic.phpt new file mode 100644 index 0000000000..76e9028043 --- /dev/null +++ b/ext/posix/tests/posix_geteuid_basic.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test function posix_geteuid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +var_dump(posix_geteuid()); +?> +--EXPECTF-- +int(%d) diff --git a/ext/posix/tests/posix_seteuid_basic.phpt b/ext/posix/tests/posix_seteuid_basic.phpt new file mode 100644 index 0000000000..204ebe8d07 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test function posix_seteuid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +$myuid = posix_geteuid(); +$uid = var_dump(posix_seteuid( $myuid ) ); + +?> +--EXPECTF-- +bool(true) diff --git a/ext/posix/tests/posix_seteuid_error.phpt b/ext/posix/tests/posix_seteuid_error.phpt new file mode 100644 index 0000000000..b10e41075e --- /dev/null +++ b/ext/posix/tests/posix_seteuid_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test function posix_seteuid() by calling it more than or less than its expected arguments +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$uid = '123'; +$extra_arg = '12312'; + +var_dump(posix_seteuid( $uid, $extra_arg ) ); +var_dump(posix_seteuid( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_seteuid() expects exactly 1 parameter, 2 given in %s on line 9 +bool(false) + +Warning: posix_seteuid() expects exactly 1 parameter, 0 given in %s on line 10 +bool(false) diff --git a/ext/posix/tests/posix_seteuid_error2.phpt b/ext/posix/tests/posix_seteuid_error2.phpt new file mode 100644 index 0000000000..808f2d32d1 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_error2.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with object values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - posix_seteuid() expects parameter 1 to be long, object given, %s +bool(false) +Error: 2 - posix_seteuid() expects parameter 1 to be long, object given, %s +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation1.phpt b/ext/posix/tests/posix_seteuid_variation1.phpt new file mode 100644 index 0000000000..841bfe0db8 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with array values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + +$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(posix_seteuid( $var ) ); +} + +?> +--EXPECTF-- +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation2.phpt b/ext/posix/tests/posix_seteuid_variation2.phpt new file mode 100644 index 0000000000..2ab7302ce7 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with boolean values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation4.phpt b/ext/posix/tests/posix_seteuid_variation4.phpt new file mode 100644 index 0000000000..65291417e7 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation4.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with float values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$myUid = posix_getuid(); + +$myUid = $myUid - 1.1; + +$variation_array = array( + 'float '.$myUid => $myUid, + 'float -'.$myUid => -$myUid, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_seteuid_variation5.phpt b/ext/posix/tests/posix_seteuid_variation5.phpt new file mode 100644 index 0000000000..91d3a72e96 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with int values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int -12345' => -12345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_basic.phpt b/ext/posix/tests/posix_setgid_basic.phpt new file mode 100644 index 0000000000..5762d2b13c --- /dev/null +++ b/ext/posix/tests/posix_setgid_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test function posix_setgid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with its expected arguments ***\n"; + +$gid = posix_getgid(); +var_dump(posix_setgid( $gid ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +bool(true) diff --git a/ext/posix/tests/posix_setgid_error.phpt b/ext/posix/tests/posix_setgid_error.phpt new file mode 100644 index 0000000000..121b0403c8 --- /dev/null +++ b/ext/posix/tests/posix_setgid_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function posix_setgid() by calling it more than or less than its expected arguments. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$gid = posix_getgid(); +$extra_arg = '123'; + +var_dump(posix_setgid( $gid, $extra_arg ) ); +var_dump(posix_setgid( ) ); + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_setgid() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +Warning: posix_setgid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation1.phpt b/ext/posix/tests/posix_setgid_variation1.phpt new file mode 100644 index 0000000000..9125327aa9 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with array values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, array given in %s on line %d +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation2.phpt b/ext/posix/tests/posix_setgid_variation2.phpt new file mode 100644 index 0000000000..77d614f05c --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation2.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with boolean values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation4.phpt b/ext/posix/tests/posix_setgid_variation4.phpt new file mode 100644 index 0000000000..62acf23f39 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation4.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with float values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation5.phpt b/ext/posix/tests/posix_setgid_variation5.phpt new file mode 100644 index 0000000000..f7e60a4a84 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation5.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with int values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'long 0' => 0, + 'long 1' => 1, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setgid_variation6.phpt b/ext/posix/tests/posix_setgid_variation6.phpt new file mode 100644 index 0000000000..e1bdfb131a --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation6.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test function posix_setgid() by substituting argument 1 with object values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - posix_setgid() expects parameter 1 to be long, object given, %s +bool(false) +Error: 2 - posix_setgid() expects parameter 1 to be long, object given, %s +bool(false) diff --git a/ext/posix/tests/posix_setuid_basic.phpt b/ext/posix/tests/posix_setuid_basic.phpt new file mode 100644 index 0000000000..986b0be62c --- /dev/null +++ b/ext/posix/tests/posix_setuid_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test function posix_setuid() by calling it with its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php + +$myuid = posix_getuid(); +$uid = var_dump(posix_setuid( $myuid ) ); + +?> +--EXPECTF-- +bool(true) diff --git a/ext/posix/tests/posix_setuid_error.phpt b/ext/posix/tests/posix_setuid_error.phpt new file mode 100644 index 0000000000..8aa51586a4 --- /dev/null +++ b/ext/posix/tests/posix_setuid_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function posix_setuid() by calling it more than or less than its expected arguments +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$uid = '123'; + + +$extra_arg = '12312'; + +var_dump(posix_setuid( $uid, $extra_arg ) ); + +var_dump(posix_setuid( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_setuid() expects exactly 1 parameter, 2 given in %s on line 11 +bool(false) + +Warning: posix_setuid() expects exactly 1 parameter, 0 given in %s on line 13 +bool(false) diff --git a/ext/posix/tests/posix_setuid_error2.phpt b/ext/posix/tests/posix_setuid_error2.phpt new file mode 100644 index 0000000000..6ec0aa9af4 --- /dev/null +++ b/ext/posix/tests/posix_setuid_error2.phpt @@ -0,0 +1,55 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with object values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 2 - posix_setuid() expects parameter 1 to be long, object given, %s +bool(false) +Error: 2 - posix_setuid() expects parameter 1 to be long, object given, %s +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation1.phpt b/ext/posix/tests/posix_setuid_variation1.phpt new file mode 100644 index 0000000000..bf6d4376cd --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation1.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with array values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + +$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(posix_setuid( $var ) ); +} + +?> +--EXPECTF-- +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, array given in %s on line 15 +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation2.phpt b/ext/posix/tests/posix_setuid_variation2.phpt new file mode 100644 index 0000000000..c8ef92827f --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with boolean values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation4.phpt b/ext/posix/tests/posix_setuid_variation4.phpt new file mode 100644 index 0000000000..1675964920 --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation4.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with float values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with float values ***\n"; + +$myUid = posix_getuid(); + +$myUid = $myUid - 1.1; + +$variation_array = array( + 'float '.$myUid => $myUid, + 'float -'.$myUid => -$myUid, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_setuid_variation5.phpt b/ext/posix/tests/posix_setuid_variation5.phpt new file mode 100644 index 0000000000..e1b7c05e0e --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with int values. +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 0' => 0, + 'int 1' => 1, + 'int -12345' => -12345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_error.phpt b/ext/posix/tests/posix_ttyname_error.phpt new file mode 100644 index 0000000000..e3ec695e54 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test function posix_ttyname() by calling it more than or less than its expected arguments +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test by calling method or function with incorrect numbers of arguments ***\n"; + +$fd = 'foo'; +$extra_arg = 'bar'; + +var_dump(posix_ttyname( $fd, $extra_arg ) ); + +var_dump(posix_ttyname( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_ttyname() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +Warning: posix_ttyname() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation1.phpt b/ext/posix/tests/posix_ttyname_variation1.phpt new file mode 100644 index 0000000000..072b9fa672 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation1.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with array values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation2.phpt b/ext/posix/tests/posix_ttyname_variation2.phpt new file mode 100644 index 0000000000..f46821b0cc --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation2.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with boolean values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation3.phpt b/ext/posix/tests/posix_ttyname_variation3.phpt new file mode 100644 index 0000000000..30054265a0 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation3.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with emptyUnsetUndefNull values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_ttyname( $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/posix/tests/posix_ttyname_variation4.phpt b/ext/posix/tests/posix_ttyname_variation4.phpt new file mode 100644 index 0000000000..3215492793 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation4.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with float values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation5.phpt b/ext/posix/tests/posix_ttyname_variation5.phpt new file mode 100644 index 0000000000..661dd606f9 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation5.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with int values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with int values ***\n"; + + + +$variation_array = array ( + 'int 12345' => 12345, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation6.phpt b/ext/posix/tests/posix_ttyname_variation6.phpt new file mode 100644 index 0000000000..020aef1156 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation6.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with object values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--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(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +Error: 8 - Object of class classWithToString could not be converted to int, %s(%d) +bool(false) +Error: 8 - Object of class classWithoutToString could not be converted to int, %s(%d) +bool(false) diff --git a/ext/posix/tests/posix_ttyname_variation7.phpt b/ext/posix/tests/posix_ttyname_variation7.phpt new file mode 100644 index 0000000000..b39916c5bc --- /dev/null +++ b/ext/posix/tests/posix_ttyname_variation7.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test function posix_ttyname() by substituting argument 1 with string values. +--CREDITS-- +Marco Fabbri mrfabbri@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with 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(posix_ttyname( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** +bool(false) +bool(false) +bool(false) +bool(false) |