Annotation of embedaddon/php/ext/standard/tests/network/fsockopen_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test fsockopen() function : error conditions 
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : proto resource fsockopen(string hostname, int port [, int errno [, string errstr [, float timeout]]])
                      6:  * Description: Open Internet or Unix domain socket connection 
                      7:  * Source code: ext/standard/fsock.c
                      8:  * Alias to functions: 
                      9:  */
                     10: 
                     11: 
                     12: echo "*** Testing fsockopen() : basic error conditions ***\n";
                     13: 
                     14: 
                     15: echo "\n-- Testing fsockopen() function with more than expected no. of arguments --\n";
                     16: $hostname = 'string_val';
                     17: $port = 10;
                     18: $errno = 10;
                     19: $errstr = 'string_val';
                     20: $timeout = 10.5;
                     21: $extra_arg = 10;
                     22: var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout, $extra_arg) );
                     23: var_dump($errstr);
                     24: var_dump($errno);
                     25: 
                     26: echo "\n-- Testing fsockopen() function with less than expected no. of arguments --\n";
                     27: var_dump( fsockopen() );
                     28: 
                     29: echo "\n-- Attempting to connect to a non-existent socket --\n";
                     30: $hostname = 'tcp://127.0.0.1'; // loopback address
                     31: $port = 31337;
                     32: $errno = null;
                     33: $errstr = null;
                     34: $timeout = 1.5;
                     35: var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) );
                     36: var_dump($errstr);
                     37: 
                     38: echo "\n-- Attempting to connect using an invalid protocol --\n";
                     39: $hostname = 'invalid://127.0.0.1'; // loopback address
                     40: $port = 31337;
                     41: $errno = null;
                     42: $errstr = null;
                     43: $timeout = 1.5;
                     44: var_dump( fsockopen($hostname, $port, $errno, $errstr, $timeout) );
                     45: var_dump($errstr);
                     46: 
                     47: echo "Done";
                     48: ?>
                     49: --EXPECTF--
                     50: *** Testing fsockopen() : basic error conditions ***
                     51: 
                     52: -- Testing fsockopen() function with more than expected no. of arguments --
                     53: 
                     54: Warning: fsockopen() expects at most 5 parameters, 6 given in %s on line %d
                     55: bool(false)
                     56: string(10) "string_val"
                     57: int(10)
                     58: 
                     59: -- Testing fsockopen() function with less than expected no. of arguments --
                     60: 
                     61: Warning: fsockopen() expects at least 1 parameter, 0 given in %s on line %d
                     62: bool(false)
                     63: 
                     64: -- Attempting to connect to a non-existent socket --
                     65: 
                     66: Warning: fsockopen(): unable to connect to tcp://127.0.0.1:31337 (%a) in %s on line %d
                     67: bool(false)
                     68: string(%d) "%a"
                     69: 
                     70: -- Attempting to connect using an invalid protocol --
                     71: 
                     72: 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
                     73: bool(false)
                     74: string(100) "Unable to find the socket transport "invalid" - did you forget to enable it when you configured PHP?"
                     75: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>