diff options
| author | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
| commit | 0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch) | |
| tree | 91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/posix | |
| parent | d3a8757891280dc6650ca7eead67830c794b0e7b (diff) | |
| download | php-upstream/5.3.1.tar.gz | |
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/posix')
53 files changed, 1573 insertions, 13 deletions
diff --git a/ext/posix/config.m4 b/ext/posix/config.m4 index 9f648536d..eb02958af 100644 --- a/ext/posix/config.m4 +++ b/ext/posix/config.m4 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4,v 1.12.4.5.2.2 2009/01/21 19:22:39 jani Exp $ +dnl $Id: config.m4 274134 2009-01-21 19:22:39Z jani $ dnl PHP_ARG_ENABLE(posix,whether to enable POSIX-like functions, diff --git a/ext/posix/php_posix.h b/ext/posix/php_posix.h index eff709190..fdc69b79e 100644 --- a/ext/posix/php_posix.h +++ b/ext/posix/php_posix.h @@ -17,7 +17,7 @@ */ -/* $Id: php_posix.h,v 1.18.2.1.2.2.2.2 2008/12/31 11:15:42 sebastian Exp $ */ +/* $Id: php_posix.h 272370 2008-12-31 11:15:49Z sebastian $ */ #ifndef PHP_POSIX_H #define PHP_POSIX_H diff --git a/ext/posix/posix.c b/ext/posix/posix.c index beedd3894..1e6c5eccc 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: posix.c,v 1.70.2.3.2.16.2.15 2009/06/06 02:40:48 mattwil Exp $ */ +/* $Id: posix.c 289424 2009-10-09 14:46:48Z pajoye $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -310,7 +310,7 @@ const zend_function_entry posix_functions[] = { static PHP_MINFO_FUNCTION(posix) { php_info_print_table_start(); - php_info_print_table_row(2, "Revision", "$Revision: 1.70.2.3.2.16.2.15 $"); + php_info_print_table_row(2, "Revision", "$Revision: 289424 $"); php_info_print_table_end(); } /* }}} */ @@ -651,7 +651,7 @@ PHP_FUNCTION(posix_times) PHP_POSIX_NO_ARGS; - if((ticks = times(&t)) < 0) { + if ((ticks = times(&t)) == -1) { POSIX_G(last_error) = errno; RETURN_FALSE; } @@ -840,7 +840,8 @@ PHP_FUNCTION(posix_mkfifo) RETURN_FALSE; } - if (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR))) { + if (php_check_open_basedir_ex(path, 0 TSRMLS_CC) || + (PG(safe_mode) && (!php_checkuid(path, NULL, CHECKUID_ALLOW_ONLY_DIR)))) { RETURN_FALSE; } @@ -1361,6 +1362,10 @@ PHP_FUNCTION(posix_initgroups) RETURN_FALSE; } + if (name_len == 0) { + RETURN_FALSE; + } + RETURN_BOOL(!initgroups((const char *)name, basegid)); } /* }}} */ diff --git a/ext/posix/tests/posix_ctermid_basic.phpt b/ext/posix/tests/posix_ctermid_basic.phpt new file mode 100644 index 000000000..d1d46943b --- /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_ctermid_error.phpt b/ext/posix/tests/posix_ctermid_error.phpt new file mode 100644 index 000000000..a177f5457 --- /dev/null +++ b/ext/posix/tests/posix_ctermid_error.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test function posix_ctermid() 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 + +var_dump( posix_ctermid( 'foo' ) ); + +?> +--EXPECTF-- +Warning: posix_ctermid() expects exactly 0 parameters, 1 given in %s on line %d +NULL diff --git a/ext/posix/tests/posix_errno_basic.phpt b/ext/posix/tests/posix_errno_basic.phpt new file mode 100644 index 000000000..cd94a9751 --- /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_error.phpt b/ext/posix/tests/posix_errno_error.phpt new file mode 100644 index 000000000..0a77fb000 --- /dev/null +++ b/ext/posix/tests/posix_errno_error.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test function posix_errno() by calling it with its expected arguments +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--CREDITS-- +Morten Amundsen mor10am@gmail.com +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--FILE-- +<?php + +echo "*** Test by calling method or function with more than expected arguments ***\n"; + +// test without any error +var_dump(posix_errno('bar')); + +?> +--EXPECTF-- +*** Test by calling method or function with more than expected arguments *** + +Warning: posix_errno() expects exactly 0 parameters, 1 given in %s on line %d +NULL diff --git a/ext/posix/tests/posix_errno_variation1.phpt b/ext/posix/tests/posix_errno_variation1.phpt new file mode 100644 index 000000000..aa9889f7f --- /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 000000000..f463d7875 --- /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_getcwd.phpt b/ext/posix/tests/posix_getcwd.phpt index fc5a6d43e..75c8d575b 100644 --- a/ext/posix/tests/posix_getcwd.phpt +++ b/ext/posix/tests/posix_getcwd.phpt @@ -1,6 +1,6 @@ --TEST-- posix_getcwd(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_getcwd')) die('skip posix_getcwd() not found'); diff --git a/ext/posix/tests/posix_geteuid_basic.phpt b/ext/posix/tests/posix_geteuid_basic.phpt new file mode 100644 index 000000000..76e902804 --- /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_geteuid_error1.phpt b/ext/posix/tests/posix_geteuid_error1.phpt new file mode 100644 index 000000000..ac4e0d5dd --- /dev/null +++ b/ext/posix/tests/posix_geteuid_error1.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test function posix_geteuid() 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"; + +$extra_args = array( 12312, 2 => '1234', 'string' => 'string' ); + +var_dump( posix_geteuid( $extra_args )); +foreach ( $extra_args as $arg ) +{ + var_dump(posix_geteuid( $arg )); +} + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: posix_geteuid() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +Warning: posix_geteuid() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +Warning: posix_geteuid() expects exactly 0 parameters, 1 given in %s on line %d +NULL + +Warning: posix_geteuid() expects exactly 0 parameters, 1 given in %s on line %d +NULL diff --git a/ext/posix/tests/posix_getgrnam.phpt b/ext/posix/tests/posix_getgrnam.phpt index 9d24f085e..854db4ac1 100644 --- a/ext/posix/tests/posix_getgrnam.phpt +++ b/ext/posix/tests/posix_getgrnam.phpt @@ -1,6 +1,6 @@ --TEST-- posix_getgrnam(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_getgrnam')) die('skip posix_getgrnam() not found'); diff --git a/ext/posix/tests/posix_getpwnam.phpt b/ext/posix/tests/posix_getpwnam.phpt index 4b8962297..b5de1e4ce 100644 --- a/ext/posix/tests/posix_getpwnam.phpt +++ b/ext/posix/tests/posix_getpwnam.phpt @@ -1,6 +1,6 @@ --TEST-- posix_getpwnam(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_getpwnam')) die('skip posix_getpwnam() not found'); diff --git a/ext/posix/tests/posix_getrlimit.phpt b/ext/posix/tests/posix_getrlimit.phpt index 55bd8aff8..61da64a93 100644 --- a/ext/posix/tests/posix_getrlimit.phpt +++ b/ext/posix/tests/posix_getrlimit.phpt @@ -1,6 +1,6 @@ --TEST-- posix_getrlimit(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_getrlimit')) die('skip posix_getrlimit() not found'); diff --git a/ext/posix/tests/posix_initgroups.phpt b/ext/posix/tests/posix_initgroups.phpt index 6ffb202f3..60121e845 100644 --- a/ext/posix/tests/posix_initgroups.phpt +++ b/ext/posix/tests/posix_initgroups.phpt @@ -1,6 +1,6 @@ --TEST-- posix_initgroups(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_initgroups')) die('skip posix_initgroups() not found'); diff --git a/ext/posix/tests/posix_isatty.phpt b/ext/posix/tests/posix_isatty.phpt index 74309c299..0b40dd1d4 100644 --- a/ext/posix/tests/posix_isatty.phpt +++ b/ext/posix/tests/posix_isatty.phpt @@ -1,6 +1,6 @@ --TEST-- posix_isatty(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_isatty')) die('skip posix_isatty() not found'); diff --git a/ext/posix/tests/posix_mknod.phpt b/ext/posix/tests/posix_mknod.phpt index 1063abe5d..4044fb98d 100644 --- a/ext/posix/tests/posix_mknod.phpt +++ b/ext/posix/tests/posix_mknod.phpt @@ -1,6 +1,6 @@ --TEST-- posix_mknod(): Basic tests ---SKIP-- +--SKIPIF-- <?php if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); if (!function_exists('posix_mknod')) die('skip posix_mknod() not found'); diff --git a/ext/posix/tests/posix_seteuid_basic.phpt b/ext/posix/tests/posix_seteuid_basic.phpt new file mode 100644 index 000000000..204ebe8d0 --- /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 000000000..b10e41075 --- /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 000000000..808f2d32d --- /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 000000000..841bfe0db --- /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 000000000..2ab7302ce --- /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_variation3.phpt b/ext/posix/tests/posix_seteuid_variation3.phpt new file mode 100644 index 000000000..70c05c86e --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with emptyUnsetUndefNull 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 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_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, string given in %s on line 22 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, string given in %s on line 22 +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 000000000..65291417e --- /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 000000000..91d3a72e9 --- /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_seteuid_variation6.phpt b/ext/posix/tests/posix_seteuid_variation6.phpt new file mode 100644 index 000000000..65ff56be0 --- /dev/null +++ b/ext/posix/tests/posix_seteuid_variation6.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test function posix_seteuid() by substituting argument 1 with string 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 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_seteuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** + +Warning: posix_seteuid() expects parameter 1 to be long, string given in %s on line 21 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, string given in %s on line 21 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, string given in %s on line 21 +bool(false) + +Warning: posix_seteuid() expects parameter 1 to be long, string given in %s on line 21 +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 000000000..da3751fea --- /dev/null +++ b/ext/posix/tests/posix_setgid_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function posix_setgid() by calling it with 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 its expected arguments ***\n"; + +$gid = posix_getgid(); +var_dump(posix_setgid( $gid ) ); + + +?> +===DONE=== +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +bool(true) +===DONE=== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_setgid_error.phpt b/ext/posix/tests/posix_setgid_error.phpt new file mode 100644 index 000000000..247435d94 --- /dev/null +++ b/ext/posix/tests/posix_setgid_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test function posix_setgid() by calling it more than or less than its expected arguments. +--CREDITS-- +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +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( ) ); + +?> +===DONE=== +--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) +===DONE=== diff --git a/ext/posix/tests/posix_setgid_variation1.phpt b/ext/posix/tests/posix_setgid_variation1.phpt new file mode 100644 index 000000000..3690a7718 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation1.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test function posix_setgid() 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 + + +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 ) ); +} +?> +===DONE=== +--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) +===DONE=== diff --git a/ext/posix/tests/posix_setgid_variation2.phpt b/ext/posix/tests/posix_setgid_variation2.phpt new file mode 100644 index 000000000..6d53b0837 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation2.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test function posix_setgid() 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_setgid( $var ) ); +} +?> +===DONE=== +--EXPECTF-- +*** Test substituting argument 1 with boolean values *** +bool(false) +bool(false) +bool(false) +bool(false) +===DONE=== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_setgid_variation3.phpt b/ext/posix/tests/posix_setgid_variation3.phpt new file mode 100644 index 000000000..5855746f0 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test function posix_setgid() 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 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--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_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, string given in %s on line %d +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 000000000..2bd209bd3 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation4.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test function posix_setgid() 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"; + + + +$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 ) ); +} +?> +===DONE=== +--EXPECTF-- +*** Test substituting argument 1 with float values *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +===DONE=== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_setgid_variation5.phpt b/ext/posix/tests/posix_setgid_variation5.phpt new file mode 100644 index 000000000..91f2bb593 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation5.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test function posix_setgid() 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 ( + 'long 0' => 0, + 'long 1' => 1, + 'int -12345' => -2345, + ); + + +foreach ( $variation_array as $var ) { + var_dump(posix_setgid( $var ) ); +} +?> +===DONE=== +--EXPECTF-- +*** Test substituting argument 1 with int values *** +bool(false) +bool(false) +bool(false) +===DONE=== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_setgid_variation6.phpt b/ext/posix/tests/posix_setgid_variation6.phpt new file mode 100644 index 000000000..8557fd2e8 --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation6.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test function posix_setgid() 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_setgid( $var ) ); +} +?> +===DONE=== +--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) +===DONE=== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_setgid_variation7.phpt b/ext/posix/tests/posix_setgid_variation7.phpt new file mode 100644 index 000000000..f8083c38f --- /dev/null +++ b/ext/posix/tests/posix_setgid_variation7.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test function posix_setgid() 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 +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--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_setgid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** + +Warning: posix_setgid() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: posix_setgid() expects parameter 1 to be long, string given in %s on line %d +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 000000000..986b0be62 --- /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 000000000..8aa51586a --- /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 000000000..6ec0aa9af --- /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 000000000..bf6d4376c --- /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 000000000..c8ef92827 --- /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_variation3.phpt b/ext/posix/tests/posix_setuid_variation3.phpt new file mode 100644 index 000000000..1630cd1d0 --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation3.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with emptyUnsetUndefNull 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 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_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(false) +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, string given in %s on line 22 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, string given in %s on line 22 +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 000000000..167596492 --- /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 000000000..e1b7c05e0 --- /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_setuid_variation6.phpt b/ext/posix/tests/posix_setuid_variation6.phpt new file mode 100644 index 000000000..79e614fec --- /dev/null +++ b/ext/posix/tests/posix_setuid_variation6.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test function posix_setuid() by substituting argument 1 with string 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 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_setuid( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** + +Warning: posix_setuid() expects parameter 1 to be long, string given in %s on line 21 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, string given in %s on line 21 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, string given in %s on line 21 +bool(false) + +Warning: posix_setuid() expects parameter 1 to be long, string given in %s on line 21 +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 000000000..e3ec695e5 --- /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 000000000..072b9fa67 --- /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 000000000..f46821b0c --- /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 000000000..30054265a --- /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 000000000..321549279 --- /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 000000000..661dd606f --- /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 000000000..020aef115 --- /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 000000000..b39916c5b --- /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) |
