From: Steve Seear Date: Wed, 19 Mar 2008 17:38:25 +0000 (+0000) Subject: Adding streams tests X-Git-Tag: php-5.2.6RC3~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6744f65d51d381f9f6fbf6b783eea712076d1b3f;p=php Adding streams tests --- diff --git a/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt new file mode 100644 index 0000000000..f46c8fd70b --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt @@ -0,0 +1,50 @@ +--TEST-- +stream_get_meta_data() on directories +--FILE-- +handle)); + +?> +--EXPECT-- +array(8) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(3) "dir" + ["mode"]=> + string(1) "r" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(8) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(3) "dir" + ["mode"]=> + string(1) "r" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt new file mode 100644 index 0000000000..4758c750f9 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +stream_get_meta_data() basic functionality +--FILE-- + +--EXPECTF-- +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "r" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%sstream_get_meta_data_file_basic.php" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt new file mode 100644 index 0000000000..912c4055a2 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_file_error.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test stream_get_meta_data() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing stream_get_meta_data() : error conditions *** + +-- Testing stream_get_meta_data() function with Zero arguments -- + +Warning: Wrong parameter count for stream_get_meta_data() in %s on line %i +NULL + +-- Testing stream_get_meta_data() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for stream_get_meta_data() in %s on line %i +NULL + +-- Testing stream_get_meta_data() function with invalid stream resource -- + +Warning: stream_get_meta_data(): supplied argument is not a valid stream resource in %s on line %i +bool(false) + +-- Testing stream_get_meta_data() function with closed stream resource -- + +Warning: stream_get_meta_data(): %i is not a valid stream resource in %s on line %i +bool(false) +Done diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt new file mode 100644 index 0000000000..572653e3db --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt @@ -0,0 +1,510 @@ +--TEST-- +stream_get_meta_data() with differing file access modes +--FILE-- + +--EXPECTF-- +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "r" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "w" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "a" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "a+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "x" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "x+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "rb" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "rb+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "wb" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "wb+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "ab" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "ab+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "xb" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "xb+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "rt" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "rt+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "wt" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "wt+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "at" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "at+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "xt" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(3) "xt+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt new file mode 100644 index 0000000000..d186cb7e9b --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt @@ -0,0 +1,135 @@ +--TEST-- +Testing stream_get_meta_data() "unread_bytes" field +--FILE-- + +--EXPECTF-- +Write some data to the file: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read a line of the file, causing data to be buffered: +string(15) "a line of data +" +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(285) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read 20 bytes from the file: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(265) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read entire file: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(true) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt new file mode 100644 index 0000000000..c51d9bd087 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt @@ -0,0 +1,71 @@ +--TEST-- +stream_get_meta_data() with a relative file path +--FILE-- + +--EXPECTF-- +Create a file: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "File://%sstream_get_meta_data_file_variation4.php.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + +Change to file's directory and open with a relative path: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "r" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "stream_get_meta_data_file_variation4.php.tmp" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt new file mode 100644 index 0000000000..386b92f421 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt @@ -0,0 +1,77 @@ +--TEST-- +testing stream_get_meta_data() "eof" field for a file stream +--FILE-- + +--EXPECTF-- +Write some data to the file: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read entire file: +array(9) { + ["wrapper_type"]=> + string(9) "plainfile" + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "w+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(true) + ["uri"]=> + string(%i) "%s" + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(true) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_process_basic-win32.phpt b/ext/standard/tests/streams/stream_get_meta_data_process_basic-win32.phpt new file mode 100644 index 0000000000..97b7d780a5 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_process_basic-win32.phpt @@ -0,0 +1,43 @@ +--TEST-- +Testing stream_get_meta_data() on a process stream. +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(7) { + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(2) "rb" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +Done diff --git a/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt new file mode 100644 index 0000000000..6b383e75dd --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt @@ -0,0 +1,43 @@ +--TEST-- +Testing stream_get_meta_data() on a process stream. +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(7) { + ["stream_type"]=> + string(5) "STDIO" + ["mode"]=> + string(1) "r" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} +Done diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt new file mode 100644 index 0000000000..1369f25ee4 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +stream_get_meta_data() on a udp socket +--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/streams/stream_get_meta_data_socket_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt new file mode 100644 index 0000000000..f9158e4f26 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt @@ -0,0 +1,110 @@ +--TEST-- +Testing stream_get_meta_data() "unread_bytes" field on a udp socket +--FILE-- + +--EXPECT-- +Write some data: +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) +} + + +Read a line from the client, causing data to be buffered: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(15) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read 3 bytes of data from the client: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(12) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Close the server side socket and read the remaining data from the client: +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(true) +} diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt new file mode 100644 index 0000000000..e6b3e04142 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt @@ -0,0 +1,108 @@ +--TEST-- +Testing stream_get_meta_data() "timed_out" field on a udp socket +--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) +} + + +Set a timeout on the client and attempt a read: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(true) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Write some data from the server: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(0) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(true) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read some data from the client: +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/streams/stream_get_meta_data_socket_variation3.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt new file mode 100644 index 0000000000..f467971047 --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt @@ -0,0 +1,86 @@ +--TEST-- +Testing stream_get_meta_data() "blocked" field on a udp socket +--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) +} + + +Set blocking to false: +bool(true) +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(false) + ["eof"]=> + bool(false) +} + + +Set blocking to true: +bool(true) +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/streams/stream_get_meta_data_socket_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt new file mode 100644 index 0000000000..ebe580869c --- /dev/null +++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt @@ -0,0 +1,89 @@ +--TEST-- +Testing stream_get_meta_data() "eof" field on a udp socket +--FILE-- + +--EXPECTF-- +Write some data: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(%i) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Read a line from the client: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(%i) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(false) +} + + +Close the server side socket and read the remaining data from the client: +array(7) { + ["stream_type"]=> + string(10) "tcp_socket" + ["mode"]=> + string(2) "r+" + ["unread_bytes"]=> + int(%i) + ["seekable"]=> + bool(false) + ["timed_out"]=> + bool(false) + ["blocked"]=> + bool(true) + ["eof"]=> + bool(true) +} \ No newline at end of file diff --git a/ext/standard/tests/streams/stream_set_timeout_error.phpt b/ext/standard/tests/streams/stream_set_timeout_error.phpt new file mode 100644 index 0000000000..1e8e60bd2a --- /dev/null +++ b/ext/standard/tests/streams/stream_set_timeout_error.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test stream_set_timeout() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing stream_set_timeout() : error conditions *** + +-- Testing stream_set_timeout() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for stream_set_timeout() in %s on line %i +NULL + +-- Testing stream_set_timeout() function with less than expected no. of arguments -- + +Warning: Wrong parameter count for stream_set_timeout() in %s on line %i +NULL + +-- Testing stream_set_timeout() function with a closed socket -- + +Warning: stream_set_timeout(): %i is not a valid stream resource in %s on line %i +bool(false) + +-- Testing stream_set_timeout() function with an invalid stream -- + +Warning: stream_set_timeout(): supplied argument is not a valid stream resource in %s on line %i +bool(false) + +-- Testing stream_set_timeout() function with a stream that does not support timeouts -- +bool(false) +Done