diff options
Diffstat (limited to 'ext/standard/tests/general_functions')
64 files changed, 2255 insertions, 66 deletions
diff --git a/ext/standard/tests/general_functions/.getservbyport_basic.phpt.swp b/ext/standard/tests/general_functions/.getservbyport_basic.phpt.swp Binary files differnew file mode 100644 index 000000000..dc8000aa0 --- /dev/null +++ b/ext/standard/tests/general_functions/.getservbyport_basic.phpt.swp diff --git a/ext/standard/tests/general_functions/bug47859.phpt b/ext/standard/tests/general_functions/bug47859.phpt index 766ab889b..458a116aa 100644 --- a/ext/standard/tests/general_functions/bug47859.phpt +++ b/ext/standard/tests/general_functions/bug47859.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #47859 parse_ini_file() does not like asterisk (*) in key in the beginning +Bug #47859 (parse_ini_file() does not like asterisk (*) in key in the beginning) --FILE-- <?php var_dump(parse_ini_string('*key = "*value"')); diff --git a/ext/standard/tests/general_functions/bug48660.phpt b/ext/standard/tests/general_functions/bug48660.phpt new file mode 100644 index 000000000..4c1492a18 --- /dev/null +++ b/ext/standard/tests/general_functions/bug48660.phpt @@ -0,0 +1,58 @@ +--TEST-- +Bug #48660 (parse_ini_*(): dollar sign as last character of value fails) +--FILE-- +<?php + +$ini_location = dirname(__FILE__) . '/bug48660.tmp'; + +// Build ini data +$ini_data = ' +[cases] + +Case.a = avalue +Case.b = "$dollar_sign" +Case.c = "dollar_sign$" +Case.d = "$dollar_sign$" +Case.e = 10 +'; + +// Save ini data to file +file_put_contents($ini_location, $ini_data); + +var_dump(parse_ini_file($ini_location, true, INI_SCANNER_RAW)); +var_dump(parse_ini_file($ini_location, true, INI_SCANNER_NORMAL)); + +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug48660.tmp'); ?> +--EXPECTF-- +array(1) { + ["cases"]=> + array(5) { + ["Case.a"]=> + string(6) "avalue" + ["Case.b"]=> + string(12) "$dollar_sign" + ["Case.c"]=> + string(12) "dollar_sign$" + ["Case.d"]=> + string(13) "$dollar_sign$" + ["Case.e"]=> + string(2) "10" + } +} +array(1) { + ["cases"]=> + array(5) { + ["Case.a"]=> + string(6) "avalue" + ["Case.b"]=> + string(12) "$dollar_sign" + ["Case.c"]=> + string(12) "dollar_sign$" + ["Case.d"]=> + string(13) "$dollar_sign$" + ["Case.e"]=> + string(2) "10" + } +} diff --git a/ext/standard/tests/general_functions/bug48768.phpt b/ext/standard/tests/general_functions/bug48768.phpt new file mode 100644 index 000000000..ae8329ac4 --- /dev/null +++ b/ext/standard/tests/general_functions/bug48768.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #48768 (parse_ini_*() crashes with INI_SCANNER_RAW) +--FILE-- +<?php + +$ini_location = dirname(__FILE__) . '/bug48768.tmp'; + +// Build ini data +$ini_data = <<< EOT +equal = "=" + +EOT; + +// Save ini data to file +file_put_contents($ini_location, $ini_data); + +var_dump(parse_ini_file($ini_location, false, INI_SCANNER_RAW)); +var_dump(parse_ini_file($ini_location, false, INI_SCANNER_NORMAL)); + +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug48768.tmp'); ?> +--EXPECT-- +array(1) { + ["equal"]=> + string(1) "=" +} +array(1) { + ["equal"]=> + string(1) "=" +} diff --git a/ext/standard/tests/general_functions/bug49056.phpt b/ext/standard/tests/general_functions/bug49056.phpt new file mode 100644 index 000000000..208766cce --- /dev/null +++ b/ext/standard/tests/general_functions/bug49056.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #49056 (parse_ini_*() regression in 5.3.0 when using non-ASCII strings as option keys) +--FILE-- +<?php + +$string = <<<EOT +Cooking_furniture="Küchen Möbel (en)" +Küchen_Möbel="Cooking furniture (en)" +EOT; + +$filename = dirname(__FILE__) . '/bug49056.tmp'; + +file_put_contents( $filename, $string); + +var_dump(parse_ini_file($filename)); + +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug49056.tmp'); ?> +--EXPECT-- +array(2) { + ["Cooking_furniture"]=> + string(23) "Küchen Möbel (en)" + ["Küchen_Möbel"]=> + string(22) "Cooking furniture (en)" +} diff --git a/ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt b/ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt index ff715ff9b..340e4e5da 100644 --- a/ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt +++ b/ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt @@ -1,59 +1,59 @@ ---TEST--
-call_user_func_array() passes by reference if the array element is referenced, regardless of function signature.
---FILE--
-<?php
-
-function by_val($arg) {
- $arg = 'changed';
-}
-
-function by_ref(&$arg) {
- $arg = 'changed';
-}
-
-echo "------ Calling by_val() with unreferenced argument ------\n";
-$arg = array('original');
-call_user_func_array('by_val', $arg);
-var_dump($arg);
-
-echo "------ Calling by_ref() with unreferenced argument ------\n";
-$arg = array('original');
-call_user_func_array('by_ref', $arg);
-var_dump($arg);
-
-echo "------ Calling by_val() with referenced argument ------\n";
-$arg = array('original');
-$ref = &$arg[0];
-call_user_func_array('by_val', $arg);
-var_dump($arg);
-
-echo "------ Calling by_ref() with referenced argument ------\n";
-$arg = array('original');
-$ref = &$arg[0];
-call_user_func_array('by_ref', $arg);
-var_dump($arg);
-
-?>
---EXPECTF--
------- Calling by_val() with unreferenced argument ------
-array(1) {
- [0]=>
- string(8) "original"
-}
------- Calling by_ref() with unreferenced argument ------
-
-Warning: Parameter 1 to by_ref() expected to be a reference, value given in %s on line %d
-array(1) {
- [0]=>
- string(8) "original"
-}
------- Calling by_val() with referenced argument ------
-array(1) {
- [0]=>
- &string(7) "changed"
-}
------- Calling by_ref() with referenced argument ------
-array(1) {
- [0]=>
- &string(7) "changed"
-}
+--TEST-- +call_user_func_array() passes by reference if the array element is referenced, regardless of function signature. +--FILE-- +<?php + +function by_val($arg) { + $arg = 'changed'; +} + +function by_ref(&$arg) { + $arg = 'changed'; +} + +echo "------ Calling by_val() with unreferenced argument ------\n"; +$arg = array('original'); +call_user_func_array('by_val', $arg); +var_dump($arg); + +echo "------ Calling by_ref() with unreferenced argument ------\n"; +$arg = array('original'); +call_user_func_array('by_ref', $arg); +var_dump($arg); + +echo "------ Calling by_val() with referenced argument ------\n"; +$arg = array('original'); +$ref = &$arg[0]; +call_user_func_array('by_val', $arg); +var_dump($arg); + +echo "------ Calling by_ref() with referenced argument ------\n"; +$arg = array('original'); +$ref = &$arg[0]; +call_user_func_array('by_ref', $arg); +var_dump($arg); + +?> +--EXPECTF-- +------ Calling by_val() with unreferenced argument ------ +array(1) { + [0]=> + string(8) "original" +} +------ Calling by_ref() with unreferenced argument ------ + +Warning: Parameter 1 to by_ref() expected to be a reference, value given in %s on line %d +array(1) { + [0]=> + string(8) "original" +} +------ Calling by_val() with referenced argument ------ +array(1) { + [0]=> + &string(7) "changed" +} +------ Calling by_ref() with referenced argument ------ +array(1) { + [0]=> + &string(7) "changed" +} diff --git a/ext/standard/tests/general_functions/get_cfg_var_basic.phpt b/ext/standard/tests/general_functions/get_cfg_var_basic.phpt new file mode 100644 index 000000000..3fb005655 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test function get_cfg_var() by calling it with its expected arguments +--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 by calling method or function with its expected arguments ***\n"; +var_dump(get_cfg_var( 'session.use_cookies' ) ); +var_dump(get_cfg_var( 'session.serialize_handler' ) ); +var_dump(get_cfg_var( 'session.save_handler' ) ); + +?> +--EXPECTF-- +*** Test by calling method or function with its expected arguments *** +string(1) "0" +string(3) "php" +string(5) "files" diff --git a/ext/standard/tests/general_functions/get_cfg_var_error.phpt b/ext/standard/tests/general_functions/get_cfg_var_error.phpt new file mode 100644 index 000000000..1c319bf79 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test function get_cfg_var() by calling it more than or less than its expected arguments +--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 by calling method or function with incorrect numbers of arguments ***\n"; + +var_dump(get_cfg_var( 'session.use_cookies', 'session.serialize_handler' ) ); +var_dump(get_cfg_var( ) ); + + +?> +--EXPECTF-- +*** Test by calling method or function with incorrect numbers of arguments *** + +Warning: get_cfg_var() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: get_cfg_var() expects exactly 1 parameter, 0 given in %s on line %d +NULL diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation1.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation1.phpt new file mode 100644 index 000000000..4e59f288e --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation1.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with array 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 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(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: get_cfg_var() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: get_cfg_var() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: get_cfg_var() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: get_cfg_var() expects parameter 1 to be string, array given in %s on line %d +NULL 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 000000000..68495a13d --- /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 000000000..d1fb5e7dd --- /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 000000000..8dac4f8a4 --- /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 000000000..392abb32c --- /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_variation6.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation6.phpt new file mode 100644 index 000000000..d142621a1 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation6.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test function get_cfg_var() by substituting argument 1 with object 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 object values ***\n"; + + + +class classWithToString +{ + public function __toString() { + return "session.use_cookies"; + } +} + +class classWithoutToString +{ +} + +$variation_array = array( + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +string(1) "0" + +Warning: get_cfg_var() expects parameter 1 to be string, object given in %s.php on line %d +NULL 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 000000000..3b5b08c6d --- /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/get_cfg_var_variation8.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt new file mode 100644 index 000000000..22188c7e6 --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation8.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test function get_cfg_var() by calling deprecated option +--CREDITS-- +Francesco Fullone ff@ideato.it +#PHPTestFest Cesena Italia on 2009-06-20 +--INI-- +register_globals=1 +--SKIPIF-- +<?php if (version_compare(PHP_VERSION, "5.3", "<")) die("skip requires 5.3 or greater"); ?> +--FILE-- +<?php +echo "*** Test by calling method or function with deprecated option ***\n"; +var_dump(get_cfg_var( 'register_globals' ) ); + +?> +--EXPECTF-- +PHP Warning: Directive 'register_globals' is deprecated in PHP 5.3 and greater in %s on line 0 +*** Test by calling method or function with deprecated option *** +string(1) "1" + diff --git a/ext/standard/tests/general_functions/get_cfg_var_variation9.phpt b/ext/standard/tests/general_functions/get_cfg_var_variation9.phpt new file mode 100644 index 000000000..6e0ffc51f --- /dev/null +++ b/ext/standard/tests/general_functions/get_cfg_var_variation9.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test function get_cfg_var() by substituting argument with array of valid parameters. +--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 with array of valid parameters ***\n"; + + + +$heredoc = <<<EOT +hello world +EOT; + +$variation_array = array( + 'session.use_cookies', + 'session.serialize_handler', + 'session.save_handler' + ); + + +foreach ( $variation_array as $var ) { + var_dump(get_cfg_var( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument with array of valid parameters *** +string(1) "0" +string(3) "php" +string(5) "files" diff --git a/ext/standard/tests/general_functions/get_defined_constants_basic.phpt b/ext/standard/tests/general_functions/get_defined_constants_basic.phpt new file mode 100644 index 000000000..9e2e66c94 --- /dev/null +++ b/ext/standard/tests/general_functions/get_defined_constants_basic.phpt @@ -0,0 +1,39 @@ +--TEST--
+Test get_defined_constants() function : basic functionality
+--FILE--
+<?php
+/* Prototype : array get_defined_constants ([ bool $categorize ] )
+ * Description: Returns an associative array with the names of all the constants and their values
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_defined_constants() : basic functionality ***\n";
+
+var_dump(gettype(get_defined_constants(true)));
+var_dump(gettype(get_defined_constants()));
+
+$arr1 = get_defined_constants(false);
+$arr2 = get_defined_constants();
+var_dump(array_diff($arr1, $arr2));
+
+$n1 = count(get_defined_constants());
+define("USER_CONSTANT", "test");
+$arr2 = get_defined_constants();
+$n2 = count($arr2);
+
+if ($n2 == $n1 + 1 && array_key_exists("USER_CONSTANT", $arr2)) {
+ echo "TEST PASSED\n";
+} else {
+ echo "TEST FAILED\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_defined_constants() : basic functionality ***
+string(5) "array"
+string(5) "array"
+array(0) {
+}
+TEST PASSED
+===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/get_defined_constants_error.phpt b/ext/standard/tests/general_functions/get_defined_constants_error.phpt new file mode 100644 index 000000000..1092712ee --- /dev/null +++ b/ext/standard/tests/general_functions/get_defined_constants_error.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test get_defined_constants() function : error conditions +--FILE-- +<?php +/* Prototype : array get_defined_constants ([ bool $categorize ] ) + * Description: Returns an associative array with the names of all the constants and their values + * Source code: Zend/zend_builtin_functions.c + */ + +echo "*** Testing get_defined_constants() : error conditions ***\n"; + +echo "\n-- Testing get_defined_constants() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( get_defined_constants(true, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing get_defined_constants() : error conditions *** + +-- Testing get_defined_constants() function with more than expected no. of arguments -- + +Warning: get_defined_constants() expects at most 1 parameter, 2 given in %s on line 11 +NULL +===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt b/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt new file mode 100644 index 000000000..4a8eceb24 --- /dev/null +++ b/ext/standard/tests/general_functions/get_loaded_extensions_basic.phpt @@ -0,0 +1,23 @@ +--TEST--
+Test get_loaded_extensions() function : basic functionality
+--FILE--
+<?php
+/* Prototype : array get_loaded_extensions ([ bool $zend_extensions= false ] )
+ * Description: Returns an array with the names of all modules compiled and loaded
+ * Source code: Zend/zend_builtin_functions.c
+ */
+
+echo "*** Testing get_loaded_extensions() : basic functionality ***\n";
+
+echo "Get loaded extensions\n";
+var_dump(get_loaded_extensions());
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing get_loaded_extensions() : basic functionality ***
+Get loaded extensions
+array(%d) {
+%a
+}
+===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt b/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt new file mode 100644 index 000000000..d731046dc --- /dev/null +++ b/ext/standard/tests/general_functions/get_loaded_extensions_error.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test get_loaded_extensions() function : error conditions +--FILE-- +<?php +/* Prototype : array get_loaded_extensions ([ bool $zend_extensions= false ] ) + * Description: Returns an array with the names of all modules compiled and loaded + * Source code: Zend/zend_builtin_functions.c + */ + +echo "*** Testing get_loaded_extensions() : error conditions ***\n"; + +echo "\n-- Testing get_loaded_extensions() function with more than expected no. of arguments --\n"; +$res = fopen(__FILE__, "r"); +$extra_arg = 10; +var_dump( get_resource_type(true, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing get_loaded_extensions() : error conditions *** + +-- Testing get_loaded_extensions() function with more than expected no. of arguments -- + +Warning: get_resource_type() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/get_resource_type_basic.phpt b/ext/standard/tests/general_functions/get_resource_type_basic.phpt new file mode 100644 index 000000000..7ff4aec2c --- /dev/null +++ b/ext/standard/tests/general_functions/get_resource_type_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test get_resource_type() function : basic functionality +--FILE-- +<?php +/* Prototype : string get_resource_type ( resource $handle ) + * Description: Returns the resource type + * Source code: Zend/zend_builtin_functions.c + */ + +echo "*** Testing get_resource_type() : basic functionality ***\n"; + +$res = fopen(__FILE__, "r"); +var_dump(get_resource_type($res)); + +?> +===DONE=== +--EXPECT-- +*** Testing get_resource_type() : basic functionality *** +string(6) "stream" +===DONE=== diff --git a/ext/standard/tests/general_functions/get_resource_type_error.phpt b/ext/standard/tests/general_functions/get_resource_type_error.phpt new file mode 100644 index 000000000..40dcf0779 --- /dev/null +++ b/ext/standard/tests/general_functions/get_resource_type_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test get_resource_type() function : error conditions +--FILE-- +<?php +/* Prototype : string get_resource_type ( resource $handle ) + * Description: Returns the resource type + * Source code: Zend/zend_builtin_functions.c + */ + +echo "*** Testing get_resource_type() : error conditions ***\n"; + +echo "\n-- Testing get_resource_type() function with Zero arguments --\n"; +var_dump( get_resource_type() ); + +echo "\n-- Testing get_resource_type() function with more than expected no. of arguments --\n"; +$res = fopen(__FILE__, "r"); +$extra_arg = 10; +var_dump( get_resource_type($res, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing get_resource_type() : error conditions *** + +-- Testing get_resource_type() function with Zero arguments -- + +Warning: get_resource_type() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing get_resource_type() function with more than expected no. of arguments -- + +Warning: get_resource_type() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/get_resource_type_variation1.phpt b/ext/standard/tests/general_functions/get_resource_type_variation1.phpt new file mode 100644 index 000000000..2c203af1f --- /dev/null +++ b/ext/standard/tests/general_functions/get_resource_type_variation1.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test get_resource_type() function : usage variations - different data types as handle arg +--FILE-- +<?php +/* Prototype : string get_resource_type ( resource $handle ) + * Description: Returns the resource type + * Source code: Zend/zend_builtin_functions.c + */ + +echo "*** Testing get_resource_type() : variation test ***\n"; + +class Hello { + public function SayHello($arg) { + echo "Hello\n"; + } +} + +$res = fopen(__FILE__, "r"); + +$vars = array( + "bool"=>true, + "int 10"=>10, + "float 10.5"=>10.5, + "string"=>"Hello World", + "array"=>array(1,2,3,4,5), + "NULL"=>NULL, + "Object"=>new Hello() +); + +foreach($vars as $variation =>$object) { + echo "\n-- $variation --\n"; + var_dump(get_resource_type($object)); +}; + +?> +===DONE=== +--EXPECTF-- +*** Testing get_resource_type() : variation test *** + +-- bool -- + +Warning: get_resource_type() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- int 10 -- + +Warning: get_resource_type() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- float 10.5 -- + +Warning: get_resource_type() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- string -- + +Warning: get_resource_type() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- array -- + +Warning: get_resource_type() expects parameter 1 to be resource, array given in %s on line %d +NULL + +-- NULL -- + +Warning: get_resource_type() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- Object -- + +Warning: get_resource_type() expects parameter 1 to be resource, object given in %s on line %d +NULL +===DONE===
\ No newline at end of file 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 000000000..164e71afd --- /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_error.phpt b/ext/standard/tests/general_functions/getservbyname_error.phpt new file mode 100755 index 000000000..eaeec6488 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test function getservbyname() 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) +Danilo Sanchi (sanchi@grupporetina.com) +--FILE-- +<?php +$service = "www"; +$protocol = "tcp"; +$extra_arg = 12; +var_dump(getservbyname($service, $protocol, $extra_arg ) ); +var_dump(getservbyname($service)); +?> +--EXPECTF-- +Warning: getservbyname() expects exactly 2 parameters, %d given in %s on line %d +NULL + +Warning: getservbyname() expects exactly 2 parameters, %d given in %s on line %d +NULL diff --git a/ext/standard/tests/general_functions/getservbyname_variation1.phpt b/ext/standard/tests/general_functions/getservbyname_variation1.phpt new file mode 100755 index 000000000..7dd01aab3 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with array values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with array values ***\n"; + +$protocol = "tcp"; + + +$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(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with array values *** + +Warning: getservbyname() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: getservbyname() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: getservbyname() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: getservbyname() expects parameter 1 to be string, array given in %s on line %d +NULL 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 000000000..70aa56764 --- /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 000000000..3c410c55b --- /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 000000000..7e5323cca --- /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_variation13.phpt b/ext/standard/tests/general_functions/getservbyname_variation13.phpt new file mode 100755 index 000000000..8dad8cda5 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation13.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with object values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with object values ***\n"; + +$service = "www"; + + +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(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with object values *** +bool(false) + +Warning: getservbyname() expects parameter 2 to be string, object given in %s.php on line %d +NULL 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 000000000..d93b53ece --- /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 000000000..877c1d12a --- /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 000000000..d34259d2a --- /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 000000000..6033c9436 --- /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 000000000..1d3b8f6d7 --- /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_variation6.phpt b/ext/standard/tests/general_functions/getservbyname_variation6.phpt new file mode 100755 index 000000000..0dfafa622 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation6.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test function getservbyname() by substituting argument 1 with object values. +--FILE-- +<?php + + +echo "*** Test substituting argument 1 with object values ***\n"; + +$protocol = "tcp"; + + +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(getservbyname( $var , $protocol ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with object values *** +bool(false) + +Warning: getservbyname() expects parameter 1 to be string, object given in %s.php on line %d +NULL 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 000000000..a0e223c50 --- /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_variation8.phpt b/ext/standard/tests/general_functions/getservbyname_variation8.phpt new file mode 100755 index 000000000..69d1d77b6 --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyname_variation8.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function getservbyname() by substituting argument 2 with array values. +--FILE-- +<?php + + +echo "*** Test substituting argument 2 with array values ***\n"; + +$service = "www"; + + +$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(getservbyname( $service, $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 2 with array values *** + +Warning: getservbyname() expects parameter 2 to be string, array given in %s on line %d +NULL + +Warning: getservbyname() expects parameter 2 to be string, array given in %s on line %d +NULL + +Warning: getservbyname() expects parameter 2 to be string, array given in %s on line %d +NULL + +Warning: getservbyname() expects parameter 2 to be string, array given in %s on line %d +NULL 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 000000000..c1c231e14 --- /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 000000000..1695455ab --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyport_basic.phpt @@ -0,0 +1,26 @@ +--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)){ + $services = file_get_contents($file); + $service = getservbyport( 80, "tcp" ); + if(preg_match("/$service\s+80\/tcp/", $services)) { + echo "PASS\n"; + } + }else{ + echo "Services file not found in expected location\n"; + } +?> +--EXPECT-- +PASS diff --git a/ext/standard/tests/general_functions/getservbyport_error.phpt b/ext/standard/tests/general_functions/getservbyport_error.phpt new file mode 100644 index 000000000..e2c245b7e --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyport_error.phpt @@ -0,0 +1,21 @@ +--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 +$port = 80; +$protocol = "tcp"; +$extra_arg = 12; +var_dump(getservbyport( $port, $protocol, $extra_arg ) ); +var_dump(getservbyport($port)); +?> +--EXPECTF-- +Warning: getservbyport() expects exactly 2 parameters, %d given in %s on line %d +NULL + +Warning: getservbyport() expects exactly 2 parameters, %d given in %s on line %d +NULL diff --git a/ext/standard/tests/general_functions/getservbyport_variation1.phpt b/ext/standard/tests/general_functions/getservbyport_variation1.phpt new file mode 100644 index 000000000..3dd2d9abb --- /dev/null +++ b/ext/standard/tests/general_functions/getservbyport_variation1.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test function getservbyport() by calling it more than or less than its expected arguments +--DESCRIPTION-- +Test function passing invalid port number and invalid protocol name +--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 + var_dump(getservbyport( -1, "tcp" )); + var_dump(getservbyport( 80, "ppp" )); + var_dump(getservbyport( null, null)); + var_dump(getservbyport( array(), array())); + var_dump(getservbyport( array(80), array("tcp"))); + var_dump(getservbyport( array(2, 3), array("one"=>1, "two"=>2))); + var_dump(getservbyport( 2, 2)); + var_dump(getservbyport( "80", "tcp")); + var_dump(getservbyport( new stdClass(), new stdClass())); + +?> +--EXPECTF-- +bool(false) +bool(false) +bool(false) + +Warning: getservbyport() expects parameter 1 to be long, array given in %s on line %d +NULL + +Warning: getservbyport() expects parameter 1 to be long, array given in %s on line %d +NULL + +Warning: getservbyport() expects parameter 1 to be long, array given in %s on line %d +NULL +bool(false) +string(%d) "%s" + +Warning: getservbyport() expects parameter 1 to be long, object given in %s on line %d +NULL diff --git a/ext/standard/tests/general_functions/is_resource_basic.phpt b/ext/standard/tests/general_functions/is_resource_basic.phpt new file mode 100644 index 000000000..27583d3d8 --- /dev/null +++ b/ext/standard/tests/general_functions/is_resource_basic.phpt @@ -0,0 +1,92 @@ +--TEST-- +Test is_resource() function : basic functionality +--FILE-- +<?php +/* Prototype : bool is_resource ( mixed $var ) + * Description: Finds whether a variable is a resource + * Source code: ext/standard/type.c + */ + +echo "*** Testing is_resource() : basic functionality ***\n"; + +class Hello { + public function SayHello($arg) { + echo "Hello\n"; + } +} + + +$vars = array( + false, + true, + 10, + 10.5, + "Helo World", + array(1,2,3,4,5), + NULL, + new Hello()); + +$types = array( + "bool=false", + "bool=true", + "integer", + "double", + "string", + "array", + "NULL", + "object"); + +echo "\nNon-resource type cases\n"; + +for ($i=0; $i < count($vars); $i++) { + if (is_resource($vars[$i])) { + echo $types[$i]. " test returns TRUE\n"; + } else { + echo $types[$i]. " test returns FALSE\n"; + } +} + +$res = fopen(__FILE__, "r"); +echo "\nResource type..var_dump after file open returns\n"; +var_dump($res); +echo "Resource type..after file open is_resource() returns"; +if (is_resource($res)) { + echo " TRUE\n"; +} else { + echo " FALSE\n"; +} + +fclose($res); +echo "\nResource type..var_dump after file close returns\n"; +var_dump($res); +echo "Resource type..after file close is_resource() returns"; +if (is_resource($res)) { + echo " TRUE\n"; +} else { + echo " FALSE\n"; +} + + +?> +===DONE=== +--EXPECTF-- +*** Testing is_resource() : basic functionality *** + +Non-resource type cases +bool=false test returns FALSE +bool=true test returns FALSE +integer test returns FALSE +double test returns FALSE +string test returns FALSE +array test returns FALSE +NULL test returns FALSE +object test returns FALSE + +Resource type..var_dump after file open returns +resource(%d) of type (%s) +Resource type..after file open is_resource() returns TRUE + +Resource type..var_dump after file close returns +resource(%d) of type (Unknown) +Resource type..after file close is_resource() returns FALSE +===DONE=== diff --git a/ext/standard/tests/general_functions/is_resource_error.phpt b/ext/standard/tests/general_functions/is_resource_error.phpt new file mode 100644 index 000000000..acb3cb660 --- /dev/null +++ b/ext/standard/tests/general_functions/is_resource_error.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test is_resource() function : error conditions +--FILE-- +<?php +/* Prototype : bool is_resource ( mixed $var ) + * Description: Finds whether a variable is a resource + * Source code: ext/standard/type.c + */ + +echo "*** Testing is_resource() : error conditions ***\n"; + +echo "\n-- Testing is_resource() function with Zero arguments --\n"; +var_dump( is_resource() ); + +echo "\n-- Testing is_resource() function with more than expected no. of arguments --\n"; +$res = fopen(__FILE__, "r"); +$extra_arg = 10; +var_dump( is_resource($res, $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing is_resource() : error conditions *** + +-- Testing is_resource() function with Zero arguments -- + +Warning: is_resource() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing is_resource() function with more than expected no. of arguments -- + +Warning: is_resource() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/isset_basic1.phpt b/ext/standard/tests/general_functions/isset_basic1.phpt new file mode 100644 index 000000000..4c0321034 --- /dev/null +++ b/ext/standard/tests/general_functions/isset_basic1.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test isset() function : basic functionality +--FILE-- +<?php +/* Prototype : bool isset ( mixed $var [, mixed $var [, $... ]] ) + * Description: Determine if a variable is set and is not NULL + */ + +class foo {} + +echo "*** Testing isset() : basic functionality ***\n"; + +$i = 10; +$f = 10.5; +$s = "Hello"; +$a = array(1,2,3,4,5); +$b = true; +$n = NULL; +$obj = new foo; +$res = fopen(__FILE__, "r"); + +echo "Integer test: " . (isset($i) ? "YES": "NO") . "\n"; +echo "Float test: " . (isset($f) ? "YES": "NO") . "\n"; +echo "String test: " . (isset($s) ? "YES": "NO") . "\n"; +echo "Array test: " . (isset($a) ? "YES": "NO") . "\n"; +echo "Boolean test: " . (isset($b) ? "YES": "NO") . "\n"; +echo "Null test: " . (isset($n) ? "YES": "NO") . "\n"; +echo "Object test: " . (isset($obj) ? "YES": "NO") . "\n"; +echo "Resource test: " . (isset($res) ? "YES": "NO") . "\n"; + +echo "\n\nUnset the variables\n\n"; +unset($i, $f, $s, $a, $b, $n, $obj, $res); + +echo "Integer test: " . (isset($i) ? "YES": "NO") . "\n"; +echo "Float test: " . (isset($f) ? "YES": "NO") . "\n"; +echo "String test: " . (isset($s) ? "YES": "NO") . "\n"; +echo "Array test: " . (isset($a) ? "YES": "NO") . "\n"; +echo "Boolean test: " . (isset($b) ? "YES": "NO") . "\n"; +echo "Null test: " . (isset($n) ? "YES": "NO") . "\n"; +echo "Object test: " . (isset($obj) ? "YES": "NO") . "\n"; +echo "Resource test: " . (isset($res) ? "YES": "NO") . "\n"; +?> +===DONE=== +--EXPECT-- +*** Testing isset() : basic functionality *** +Integer test: YES +Float test: YES +String test: YES +Array test: YES +Boolean test: YES +Null test: NO +Object test: YES +Resource test: YES + + +Unset the variables + +Integer test: NO +Float test: NO +String test: NO +Array test: NO +Boolean test: NO +Null test: NO +Object test: NO +Resource test: NO +===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/isset_basic2.phpt b/ext/standard/tests/general_functions/isset_basic2.phpt new file mode 100644 index 000000000..9137aeb92 --- /dev/null +++ b/ext/standard/tests/general_functions/isset_basic2.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test isset() function : basic functionality +--FILE-- +<?php +/* Prototype : bool isset ( mixed $var [, mixed $var [, $... ]] ) + * Description: Determine if a variable is set and is not NULL + */ + +class foo {} + +echo "*** Testing isset() : basic functionality ***\n"; + +$i = 10; +$f = 10.5; +$s = "Hello"; +$b = true; +$n = NULL; + +echo "Test multiple scalar variables in a group\n"; +var_dump(isset($i, $f, $s, $b)); +var_dump(isset($i, $f, $s, $b, $n)); + +echo "Unset a few\n"; +unset($i, $b); + +echo "Test again\n"; +var_dump(isset($i, $f, $s, $b)); + +echo "\n\nArray test:\n"; +$arr = array(); +var_dump(isset($var)); +var_dump(isset($var[1])); +var_dump(isset($var, $var[1])); +echo "..now set\n"; +$var[1] = 10; +var_dump(isset($var)); +var_dump(isset($var[1])); +var_dump(isset($var, $var[1])); + +?> +===DONE=== +--EXPECT-- +*** Testing isset() : basic functionality *** +Test multiple scalar variables in a group +bool(true) +bool(false) +Unset a few +Test again +bool(false) + + +Array test: +bool(false) +bool(false) +bool(false) +..now set +bool(true) +bool(true) +bool(true) +===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/phpcredits2.phpt b/ext/standard/tests/general_functions/phpcredits2.phpt index 9c5148b1d..ee17f598f 100644 --- a/ext/standard/tests/general_functions/phpcredits2.phpt +++ b/ext/standard/tests/general_functions/phpcredits2.phpt @@ -1,7 +1,5 @@ --TEST-- phpcredits() CGI ---SKIPIF-- -<?php if (php_sapi_name()=='cli') echo 'skip'; ?> --POST-- dummy=x --FILE-- diff --git a/ext/standard/tests/general_functions/phpinfo2.phpt b/ext/standard/tests/general_functions/phpinfo2.phpt index cf65e0c98..891867f2e 100644 --- a/ext/standard/tests/general_functions/phpinfo2.phpt +++ b/ext/standard/tests/general_functions/phpinfo2.phpt @@ -1,7 +1,5 @@ --TEST-- phpinfo() CGI ---SKIPIF-- -<?php if (php_sapi_name()=='cli') echo 'skip'; ?> --POST-- dummy=x --FILE-- 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 000000000..5a9575627 --- /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 000000000..c50812c86 --- /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 000000000..b86155c4b --- /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 000000000..620fe9144 --- /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_variation3.phpt b/ext/standard/tests/general_functions/proc_nice_variation3.phpt new file mode 100644 index 000000000..458126db4 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation3.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with emptyUnsetUndefNull 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 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(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with emptyUnsetUndefNull values *** +bool(true) +bool(true) + +Warning: proc_nice() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, string given in %s on line %d +bool(false) +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 000000000..d8325106b --- /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 000000000..b4babd593 --- /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) diff --git a/ext/standard/tests/general_functions/proc_nice_variation7.phpt b/ext/standard/tests/general_functions/proc_nice_variation7.phpt new file mode 100644 index 000000000..70487dd09 --- /dev/null +++ b/ext/standard/tests/general_functions/proc_nice_variation7.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test function proc_nice() by substituting argument 1 with string 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 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(proc_nice( $var ) ); +} +?> +--EXPECTF-- +*** Test substituting argument 1 with string values *** + +Warning: proc_nice() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Warning: proc_nice() expects parameter 1 to be long, string given in %s on line %d +bool(false) diff --git a/ext/standard/tests/general_functions/sleep_basic.phpt b/ext/standard/tests/general_functions/sleep_basic.phpt new file mode 100644 index 000000000..cfc00c6ea --- /dev/null +++ b/ext/standard/tests/general_functions/sleep_basic.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test sleep() function : basic functionality +--FILE-- +<?php +/* Prototype : int sleep ( int $seconds ) + * Description: Delays the program execution for the given number of seconds . + * Source code: ext/standard/basic_functions.c + */ + +echo "*** Testing sleep() : basic functionality ***\n"; + +$sleeptime = 5; // sleep for 5 seconds + +set_time_limit(20); + +$time_start = microtime(true); + +// Sleep for a while +sleep($sleeptime); + +// Test passes if sleeps for at least 98% of specified time +$sleeplow = $sleeptime - ($sleeptime * 2 /100); + +$time_end = microtime(true); +$time = $time_end - $time_start; + +echo "Thread slept for " . $time . " seconds\n"; + +if ($time >= $sleeplow) { + echo "TEST PASSED\n"; +} else { + echo "TEST FAILED - time is ${time} secs and sleep was ${sleeptime} secs\n"; +} +?> +===DONE=== +--EXPECTF-- +*** Testing sleep() : basic functionality *** +Thread slept for %f seconds +TEST PASSED +===DONE=== diff --git a/ext/standard/tests/general_functions/sleep_error.phpt b/ext/standard/tests/general_functions/sleep_error.phpt new file mode 100644 index 000000000..199bd8e9b --- /dev/null +++ b/ext/standard/tests/general_functions/sleep_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test sleep() function : error conditions +--FILE-- +<?php +/* Prototype : int sleep ( int $seconds ) + * Description: Delays the program execution for the given number of seconds . + * Source code: ext/standard/basic_functions.c + */ + set_time_limit(20); + +echo "*** Testing sleep() : error conditions ***\n"; + +echo "\n-- Testing sleep() function with zero arguments --\n"; +var_dump( sleep() ); + +echo "\n-- Testing sleep() function with more than expected no. of arguments --\n"; +$seconds = 10; +$extra_arg = 10; +var_dump( sleep($seconds, $extra_arg) ); + +echo "\n-- Testing sleep() function with negative interval --\n"; +$seconds = -10; +var_dump( sleep($seconds) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing sleep() : error conditions *** + +-- Testing sleep() function with zero arguments -- + +Warning: sleep() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing sleep() function with more than expected no. of arguments -- + +Warning: sleep() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing sleep() function with negative interval -- + +Warning: sleep(): Number of seconds must be greater than or equal to 0 in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/general_functions/uniqid_basic.phpt b/ext/standard/tests/general_functions/uniqid_basic.phpt new file mode 100644 index 000000000..9a9c57332 --- /dev/null +++ b/ext/standard/tests/general_functions/uniqid_basic.phpt @@ -0,0 +1,73 @@ +--TEST--
+Test uniqid() function : basic functionality
+--FILE--
+<?php
+/* Prototype : string uniqid ([ string $prefix= "" [, bool $more_entropy= false ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : basic functionality ***\n";
+
+echo "\nuniqid() without a prefix\n";
+var_dump(uniqid());
+var_dump(uniqid(null, true));
+var_dump(uniqid(null, false));
+echo "\n\n";
+
+echo "uniqid() with a prefix\n";
+
+// Use a fixed prefix so we can ensure length of o/p id is fixed
+$prefix = array (
+ 99999,
+ "99999",
+ 10.5e2,
+ null,
+ true,
+ false
+ );
+
+for ($i = 0; $i < count($prefix); $i++) {
+ var_dump(uniqid($prefix[$i]));
+ var_dump(uniqid($prefix[$i], true));
+ var_dump(uniqid($prefix[$i], false));
+ echo "\n";
+}
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : basic functionality ***
+
+uniqid() without a prefix
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+
+uniqid() with a prefix
+string(18) "99999%s"
+string(28) "99999%s.%s"
+string(18) "99999%s"
+
+string(18) "999994%s"
+string(28) "999994%s.%s"
+string(18) "999994%s"
+
+string(17) "1050%s"
+string(27) "1050%s.%s"
+string(17) "1050%s"
+
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+string(14) "1%s"
+string(24) "1%s.%s"
+string(14) "1%s"
+
+string(13) "%s"
+string(23) "%s.%s"
+string(13) "%s"
+
+===DONE===
+
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/uniqid_error.phpt b/ext/standard/tests/general_functions/uniqid_error.phpt new file mode 100644 index 000000000..96084313c --- /dev/null +++ b/ext/standard/tests/general_functions/uniqid_error.phpt @@ -0,0 +1,46 @@ +--TEST--
+Test uniqid() function : error conditions
+--FILE--
+<?php
+/* Prototype : string uniqid ([ string $prefix= "" [, bool $more_entropy= false ]] )
+ * Description: Gets a prefixed unique identifier based on the current time in microseconds.
+ * Source code: ext/standard/uniqid.c
+*/
+echo "*** Testing uniqid() : error conditions ***\n";
+
+echo "\n-- Testing uniqid() function with more than expected no. of arguments --\n";
+$prefix = null;
+$more_entropy = false;
+$extra_arg = false;
+var_dump(uniqid($prefix, $more_entropy, $extra_arg));
+
+echo "\n-- Testing uniqid() function with invalid values for \$prefix --\n";
+class class1{}
+$obj = new class1();
+$res = fopen(__FILE__, "r");
+$array = array(1,2,3);
+
+uniqid($array, false);
+uniqid($res, false);
+uniqid($obj, false);
+
+fclose($res);
+
+?>
+===DONE===
+--EXPECTF--
+*** Testing uniqid() : error conditions ***
+
+-- Testing uniqid() function with more than expected no. of arguments --
+
+Warning: uniqid() expects at most 2 parameters, 3 given in %s on line %d
+NULL
+
+-- Testing uniqid() function with invalid values for $prefix --
+
+Warning: uniqid() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string, resource given in %s on line %d
+
+Warning: uniqid() expects parameter 1 to be string, object given in %s on line %d
+===DONE===
\ No newline at end of file diff --git a/ext/standard/tests/general_functions/usleep_basic.phpt b/ext/standard/tests/general_functions/usleep_basic.phpt new file mode 100644 index 000000000..22c3e658b --- /dev/null +++ b/ext/standard/tests/general_functions/usleep_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test usleep() function +--FILE-- +<?php +/* Prototype : void usleep ( int $micro_seconds ) + * Description: Delays program execution for the given number of micro seconds. + * Source code: ext/standard/basic_functions.c + */ + +set_time_limit(20); + +echo "*** Testing usleep() : basic functionality ***\n"; + +$sleeptime = 5000000; // == 5 seconds +// Test passes if sleeps for at least 98% of specified time +$sleeplow = $sleeptime - ($sleeptime * 2 /100); + +$time_start = microtime(true); + +// Sleep for a while +usleep($sleeptime); + +$time_end = microtime(true); +$time = ($time_end - $time_start) * 1000 * 1000; + +echo "Thread slept for " . $time . " micro-seconds\n"; + +if ($time >= $sleeplow) { + echo "TEST PASSED\n"; +} else { + echo "TEST FAILED\n"; +} +?> +===DONE=== +--EXPECTF-- +*** Testing usleep() : basic functionality *** +Thread slept for %f micro-seconds +TEST PASSED +===DONE=== diff --git a/ext/standard/tests/general_functions/usleep_error.phpt b/ext/standard/tests/general_functions/usleep_error.phpt new file mode 100644 index 000000000..bdd120cde --- /dev/null +++ b/ext/standard/tests/general_functions/usleep_error.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test usleep() function : error conditions +--FILE-- +<?php +/* Prototype : void usleep ( int $micro_seconds ) + * Description: Delays program execution for the given number of micro seconds. + * Source code: ext/standard/basic_functions.c + */ + +set_time_limit(20); + +echo "*** Testing usleep() : error conditions ***\n"; + +echo "\n-- Testing usleep() function with zero arguments --\n"; +var_dump( usleep() ); + +echo "\n-- Testing usleep() function with more than expected no. of arguments --\n"; +$seconds = 10; +$extra_arg = 10; +var_dump( usleep($seconds, $extra_arg) ); + +echo "\n-- Testing usleep() function with negative interval --\n"; +$seconds = -10; +var_dump( usleep($seconds) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing usleep() : error conditions *** + +-- Testing usleep() function with zero arguments -- + +Warning: usleep() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing usleep() function with more than expected no. of arguments -- + +Warning: usleep() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +-- Testing usleep() function with negative interval -- + +Warning: usleep(): Number of microseconds must be greater than or equal to 0 in %s on line %d +bool(false) +===DONE=== diff --git a/ext/standard/tests/general_functions/var_dump_64bit.phpt b/ext/standard/tests/general_functions/var_dump_64bit.phpt index fc076a0c2..3772536cf 100644 --- a/ext/standard/tests/general_functions/var_dump_64bit.phpt +++ b/ext/standard/tests/general_functions/var_dump_64bit.phpt @@ -462,7 +462,8 @@ string(34) "abcd -- Iteration 14 -- string(22) "1234 5678 - 9100
abcda" + 9100 +abcda" *** Testing var_dump() on boolean variables *** -- Iteration 1 -- @@ -1302,7 +1303,8 @@ array(14) { [13]=> string(22) "1234 5678 - 9100
abcda" + 9100 +abcda" } array(15) { [0]=> |
