Annotation of embedaddon/php/ext/standard/tests/streams/stream_set_timeout_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test stream_set_timeout() function : error conditions
3: --FILE--
4: <?php
5: /* Prototype : proto bool stream_set_timeout(resource stream, int seconds, int microseconds)
6: * Description: Set timeout on stream read to seconds + microseonds
7: * Source code: ext/standard/streamsfuncs.c
8: * Alias to functions: socket_set_timeout
9: */
10:
11: echo "*** Testing stream_set_timeout() : error conditions ***\n";
12:
13: //Test stream_set_timeout with one more than the expected number of arguments
14: echo "\n-- Testing stream_set_timeout() function with more than expected no. of arguments --\n";
15:
16: /* Setup socket server */
17: $server = stream_socket_server('tcp://127.0.0.1:31337');
18: /* Connect to it */
19: $client = fsockopen('tcp://127.0.0.1:31337');
20:
21: $seconds = 10;
22: $microseconds = 10;
23: $extra_arg = 10;
24: var_dump( stream_set_timeout($client, $seconds, $microseconds, $extra_arg) );
25:
26: // Testing stream_set_timeout with one less than the expected number of arguments
27: echo "\n-- Testing stream_set_timeout() function with less than expected no. of arguments --\n";
28:
29: $seconds = 10;
30: var_dump( stream_set_timeout($client) );
31:
32:
33: echo "\n-- Testing stream_set_timeout() function with a closed socket --\n";
34: fclose($client);
35: var_dump( stream_set_timeout($client, $seconds) );
36:
37: echo "\n-- Testing stream_set_timeout() function with an invalid stream --\n";
38: var_dump( stream_set_timeout($seconds, $seconds) );
39:
40: echo "\n-- Testing stream_set_timeout() function with a stream that does not support timeouts --\n";
41: $filestream = fopen(__FILE__, "r");
42: var_dump( stream_set_timeout($filestream, $seconds) );
43:
44: fclose($filestream);
45: fclose($server);
46:
47: echo "Done";
48: ?>
49: --EXPECTF--
50: *** Testing stream_set_timeout() : error conditions ***
51:
52: -- Testing stream_set_timeout() function with more than expected no. of arguments --
53:
54: Warning: stream_set_timeout() expects at most 3 parameters, 4 given in %s on line %i
55: NULL
56:
57: -- Testing stream_set_timeout() function with less than expected no. of arguments --
58:
59: Warning: stream_set_timeout() expects at least 2 parameters, 1 given in %s on line %i
60: NULL
61:
62: -- Testing stream_set_timeout() function with a closed socket --
63:
64: Warning: stream_set_timeout(): %i is not a valid stream resource in %s on line %i
65: bool(false)
66:
67: -- Testing stream_set_timeout() function with an invalid stream --
68:
69: Warning: stream_set_timeout() expects parameter 1 to be resource, integer given in %s on line %i
70: NULL
71:
72: -- Testing stream_set_timeout() function with a stream that does not support timeouts --
73: bool(false)
74: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>