Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / streams / stream_set_timeout_error.phpt
blobc1d4d1406f5a0c56a214dd032e34cfab2a06f2ba
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  */
11 echo "*** Testing stream_set_timeout() : error conditions ***\n";
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";
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');
21 $seconds = 10;
22 $microseconds = 10;
23 $extra_arg = 10;
24 var_dump( stream_set_timeout($client, $seconds, $microseconds, $extra_arg) );
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";
29 $seconds = 10;
30 var_dump( stream_set_timeout($client) );
33 echo "\n-- Testing stream_set_timeout() function with a closed socket --\n";
34 fclose($client);
35 var_dump( stream_set_timeout($client, $seconds) );
37 echo "\n-- Testing stream_set_timeout() function with an invalid stream --\n";
38 var_dump( stream_set_timeout($seconds, $seconds) );
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) );
44 fclose($filestream);
45 fclose($server);
47 echo "Done";
49 --EXPECTF--
50 *** Testing stream_set_timeout() : error conditions ***
52 -- Testing stream_set_timeout() function with more than expected no. of arguments --
54 Warning: stream_set_timeout() expects at most 3 parameters, 4 given in %s on line %i
55 NULL
57 -- Testing stream_set_timeout() function with less than expected no. of arguments --
59 Warning: stream_set_timeout() expects at least 2 parameters, 1 given in %s on line %i
60 NULL
62 -- Testing stream_set_timeout() function with a closed socket --
64 Warning: stream_set_timeout(): %i is not a valid stream resource in %s on line %i
65 bool(false)
67 -- Testing stream_set_timeout() function with an invalid stream --
69 Warning: stream_set_timeout() expects parameter 1 to be resource, integer given in %s on line %i
70 NULL
72 -- Testing stream_set_timeout() function with a stream that does not support timeouts --
73 bool(false)
74 Done