From: Dave Kelsey Date: Fri, 23 Jan 2009 15:34:21 +0000 (+0000) Subject: various network tests. tested on windows, linux, linux 64 bit X-Git-Tag: php-5.3.0beta1~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a4fc75c5432463fbea83b3c112dac8b5110df8c;p=php various network tests. tested on windows, linux, linux 64 bit --- diff --git a/ext/standard/tests/network/closelog_basic.phpt b/ext/standard/tests/network/closelog_basic.phpt new file mode 100644 index 0000000000..06798a5c1d --- /dev/null +++ b/ext/standard/tests/network/closelog_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test closelog() function : basic functionality +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing closelog() : basic functionality *** + +-- Testing closelog() function with Zero arguments -- +bool(true) +===DONE=== diff --git a/ext/standard/tests/network/closelog_error.phpt b/ext/standard/tests/network/closelog_error.phpt new file mode 100644 index 0000000000..ad3fdf557d --- /dev/null +++ b/ext/standard/tests/network/closelog_error.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test closelog() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing closelog() : error conditions *** + +-- Testing closelog() function with one argument -- + +Warning: closelog() expects exactly 0 parameters, 1 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_basic-win32.phpt b/ext/standard/tests/network/define_syslog_variables_basic-win32.phpt new file mode 100644 index 0000000000..395e3afaba --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_basic-win32.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test define_syslog_variables() function : basic functionality +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing define_syslog_variables() : basic functionality *** + +Deprecated: Function define_syslog_variables() is deprecated in %s on line %d +NULL +PASSED +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_basic.phpt b/ext/standard/tests/network/define_syslog_variables_basic.phpt new file mode 100644 index 0000000000..8ccb16a9e3 --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_basic.phpt @@ -0,0 +1,126 @@ +--TEST-- +Test define_syslog_variables() function : basic functionality +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing define_syslog_variables() : basic functionality *** + +Deprecated: Function define_syslog_variables() is deprecated in %s on line %d +NULL +PASSED +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_error.phpt b/ext/standard/tests/network/define_syslog_variables_error.phpt new file mode 100644 index 0000000000..4348895567 --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_error.phpt @@ -0,0 +1,29 @@ +--TEST-- +Test define_syslog_variables() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing define_syslog_variables() : error conditions *** + +-- Testing define_syslog_variables() function with one argument -- + +Deprecated: Function define_syslog_variables() is deprecated in %s on line %d + +Warning: define_syslog_variables() expects exactly 0 parameters, 1 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_variation-win32.phpt b/ext/standard/tests/network/define_syslog_variables_variation-win32.phpt new file mode 100644 index 0000000000..b5bfdd263f --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_variation-win32.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test define_syslog_variables() function : variation +--INI-- +define_syslog_variables = true +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing define_syslog_variables() : variation *** +PASSED +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_variation.phpt b/ext/standard/tests/network/define_syslog_variables_variation.phpt new file mode 100644 index 0000000000..010dbdd388 --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_variation.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test define_syslog_variables() function : variation +--SKIPIF-- + +--INI-- +define_syslog_variables = true +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing define_syslog_variables() : variation *** +PASSED +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_variation2-win32.phpt b/ext/standard/tests/network/define_syslog_variables_variation2-win32.phpt new file mode 100644 index 0000000000..a8785fe7d6 --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_variation2-win32.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test define_syslog_variables() function : variation +--INI-- +define_syslog_variables = false +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing define_syslog_variables() : variation *** +PASSED +===DONE=== diff --git a/ext/standard/tests/network/define_syslog_variables_variation2.phpt b/ext/standard/tests/network/define_syslog_variables_variation2.phpt new file mode 100644 index 0000000000..da68df2897 --- /dev/null +++ b/ext/standard/tests/network/define_syslog_variables_variation2.phpt @@ -0,0 +1,96 @@ +--TEST-- +Test define_syslog_variables() function : variation +--SKIPIF-- + +--INI-- +define_syslog_variables = false +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing define_syslog_variables() : variation *** +PASSED +===DONE=== diff --git a/ext/standard/tests/network/fsockopen_basic.phpt b/ext/standard/tests/network/fsockopen_basic.phpt new file mode 100644 index 0000000000..3ec9366331 --- /dev/null +++ b/ext/standard/tests/network/fsockopen_basic.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test fsockopen() function : basic functionality +--FILE-- + +--EXPECTF-- +*** Testing fsockopen() : basic functionality *** +Open a server socket + +Calling fsockopen() with all possible arguments: +resource(%d) of type (stream) + +Calling fsockopen() with mandatory arguments: +resource(%d) of type (stream) + +Calling fsockopen() with address and port in same string: +resource(%d) of type (stream) +Done diff --git a/ext/standard/tests/network/fsockopen_error.phpt b/ext/standard/tests/network/fsockopen_error.phpt new file mode 100644 index 0000000000..3b13b8cf39 --- /dev/null +++ b/ext/standard/tests/network/fsockopen_error.phpt @@ -0,0 +1,75 @@ +--TEST-- +Test fsockopen() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing fsockopen() : basic error conditions *** + +-- Testing fsockopen() function with more than expected no. of arguments -- + +Warning: fsockopen() expects at most 5 parameters, 6 given in %s on line %d +bool(false) +string(10) "string_val" +int(10) + +-- Testing fsockopen() function with less than expected no. of arguments -- + +Warning: fsockopen() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +-- Attempting to connect to a non-existent socket -- + +Warning: fsockopen(): unable to connect to tcp://127.0.0.1:31337 (%a) in %s on line %d +bool(false) +string(%d) "%a" + +-- Attempting to connect using an invalid protocol -- + +Warning: fsockopen(): unable to connect to invalid://127.0.0.1:31337 (Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?) in %s on line %d +bool(false) +string(100) "Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?" +Done diff --git a/ext/standard/tests/network/fsockopen_variation1.phpt b/ext/standard/tests/network/fsockopen_variation1.phpt new file mode 100644 index 0000000000..2e5f8d9ada --- /dev/null +++ b/ext/standard/tests/network/fsockopen_variation1.phpt @@ -0,0 +1,32 @@ +--TEST-- +testing fsockopen without a protocol string +--FILE-- + +--EXPECTF-- +Open a server socket + +Calling fsockopen() without a protocol in the hostname string: +resource(%d) of type (stream) + +Calling fsockopen() with address and port in same string, without a protocol: +resource(%d) of type (stream) +Done diff --git a/ext/standard/tests/network/fsockopen_variation2.phpt b/ext/standard/tests/network/fsockopen_variation2.phpt new file mode 100644 index 0000000000..262ae0ba0f --- /dev/null +++ b/ext/standard/tests/network/fsockopen_variation2.phpt @@ -0,0 +1,48 @@ +--TEST-- +testing fsockopen() with udp sockets +--FILE-- + +--EXPECTF-- +Open a server socket + +Calling fsockopen(): +resource(%d) of type (stream) + +Pass some data between the sockets: +string(10) "0123456789" + +Calling fsockopen() with address and port in same string: +resource(%d) of type (stream) + +Pass some data between the sockets: +string(10) "0123456789" +Done diff --git a/ext/standard/tests/network/ip2long_error.phpt b/ext/standard/tests/network/ip2long_error.phpt new file mode 100644 index 0000000000..65e7315595 --- /dev/null +++ b/ext/standard/tests/network/ip2long_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test ip2long() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing ip2long() : error conditions *** + +-- Testing ip2long() function with Zero arguments -- + +Warning: ip2long() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing ip2long() function with more than expected no. of arguments -- + +Warning: ip2long() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== diff --git a/ext/standard/tests/network/ip2long_variation1.phpt b/ext/standard/tests/network/ip2long_variation1.phpt new file mode 100644 index 0000000000..18e026b87c --- /dev/null +++ b/ext/standard/tests/network/ip2long_variation1.phpt @@ -0,0 +1,199 @@ +--TEST-- +Test ip2long() function : usage variation +--FILE-- + 1, 'two' => 2); + +// resource +$res = fopen(__FILE__,'r'); + +//array of values to iterate over +$inputs = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -2345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 12.3456789000e10' => 12.3456789000e10, + 'float -12.3456789000e10' => -12.3456789000e10, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $res, +); + +// loop through each element of the array for ip_address + +foreach($inputs as $key =>$value) { + echo "\n--$key--\n"; + var_dump( ip2long($value) ); +}; + +fclose($res); + +?> +===DONE=== +--EXPECTF-- +*** Testing ip2long() : usage variation *** + +--int 0-- +int(0) + +--int 1-- +int(1) + +--int 12345-- +int(12345) + +--int -12345-- +bool(false) + +--float 10.5-- +int(167772165) + +--float -10.5-- +bool(false) + +--float 12.3456789000e10-- +bool(false) + +--float -12.3456789000e10-- +bool(false) + +--float .5-- +int(5) + +--empty array-- +Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d) +NULL + +--int indexed array-- +Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d) +NULL + +--associative array-- +Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d) +NULL + +--nested arrays-- +Error: 2 - ip2long() expects parameter 1 to be string, array given, %s(%d) +NULL + +--uppercase NULL-- +bool(false) + +--lowercase null-- +bool(false) + +--lowercase true-- +int(1) + +--lowercase false-- +bool(false) + +--uppercase TRUE-- +int(1) + +--uppercase FALSE-- +bool(false) + +--empty string DQ-- +bool(false) + +--empty string SQ-- +bool(false) + +--instance of classWithToString-- +bool(false) + +--instance of classWithoutToString-- +Error: 2 - ip2long() expects parameter 1 to be string, object given, %s(%d) +NULL + +--undefined var-- +bool(false) + +--unset var-- +bool(false) + +--resource-- +Error: 2 - ip2long() expects parameter 1 to be string, resource given, %s(%d) +NULL +===DONE=== \ No newline at end of file diff --git a/ext/standard/tests/network/long2ip_error.phpt b/ext/standard/tests/network/long2ip_error.phpt new file mode 100644 index 0000000000..d56397cdd5 --- /dev/null +++ b/ext/standard/tests/network/long2ip_error.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test long2ip() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing long2ip() : error conditions *** + +-- Testing long2ip() function with Zero arguments -- + +Warning: long2ip() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing long2ip() function with more than expected no. of arguments -- + +Warning: long2ip() 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/network/long2ip_variation1.phpt b/ext/standard/tests/network/long2ip_variation1.phpt new file mode 100644 index 0000000000..2dc6fb123b --- /dev/null +++ b/ext/standard/tests/network/long2ip_variation1.phpt @@ -0,0 +1,196 @@ +--TEST-- +Test long2ip() function : usage variation +--SKIPIF-- + +--FILE-- + 1, 'two' => 2); + +// resource +$res = fopen(__FILE__,'r'); + +//array of values to iterate over +$inputs = array( + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + // resource + 'resource' => $res, +); + +// loop through each element of the array for proper_address + +foreach($inputs as $key =>$value) { + echo "\n--$key--\n"; + var_dump( long2ip($value) ); +}; + +fclose($res); + +?> +===DONE=== +--EXPECTF-- +*** Testing long2ip() : usage variation *** + +--float 10.5-- +string(8) "0.0.0.10" + +--float -10.5-- +string(15) "255.255.255.246" + +--float .5-- +string(7) "0.0.0.0" + +--empty array-- +Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d) +NULL + +--int indexed array-- +Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d) +NULL + +--associative array-- +Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d) +NULL + +--nested arrays-- +Error: 2 - long2ip() expects parameter 1 to be string, array given, %s(%d) +NULL + +--uppercase NULL-- +string(7) "0.0.0.0" + +--lowercase null-- +string(7) "0.0.0.0" + +--lowercase true-- +string(7) "0.0.0.1" + +--lowercase false-- +string(7) "0.0.0.0" + +--uppercase TRUE-- +string(7) "0.0.0.1" + +--uppercase FALSE-- +string(7) "0.0.0.0" + +--empty string DQ-- +string(7) "0.0.0.0" + +--empty string SQ-- +string(7) "0.0.0.0" + +--string DQ-- +string(7) "0.0.0.0" + +--string SQ-- +string(7) "0.0.0.0" + +--mixed case string-- +string(7) "0.0.0.0" + +--heredoc-- +string(7) "0.0.0.0" + +--instance of classWithToString-- +string(7) "0.0.0.0" + +--instance of classWithoutToString-- +Error: 2 - long2ip() expects parameter 1 to be string, object given, %s(%d) +NULL + +--undefined var-- +string(7) "0.0.0.0" + +--unset var-- +string(7) "0.0.0.0" + +--resource-- +Error: 2 - long2ip() expects parameter 1 to be string, resource given, %s(%d) +NULL +===DONE=== diff --git a/ext/standard/tests/network/socket_get_status_basic.phpt b/ext/standard/tests/network/socket_get_status_basic.phpt new file mode 100644 index 0000000000..121ee43b43 --- /dev/null +++ b/ext/standard/tests/network/socket_get_status_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing socket_get_status() +--FILE-- + +--EXPECT-- +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} diff --git a/ext/standard/tests/network/syslog_basic-win32.phpt b/ext/standard/tests/network/syslog_basic-win32.phpt new file mode 100644 index 0000000000..88d3c5a6d9 --- /dev/null +++ b/ext/standard/tests/network/syslog_basic-win32.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test syslog() function : basic functionality +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing syslog() : basic functionality *** +bool(true) +===DONE=== diff --git a/ext/standard/tests/network/syslog_error.phpt b/ext/standard/tests/network/syslog_error.phpt new file mode 100644 index 0000000000..a99fd5314a --- /dev/null +++ b/ext/standard/tests/network/syslog_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test syslog() function : error conditions +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing syslog() : error conditions *** + +-- Testing syslog() function with more than expected no. of arguments -- + +Warning: syslog() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +-- Testing syslog() function with less than expected no. of arguments -- + +Warning: syslog() expects exactly 2 parameters, 1 given in %s on line %d +NULL +===DONE===