php-src/ext/sockets/tests/socket_import_stream-2.phpt
Gustavo André dos Santos Lopes 0de2e61cab - Added socket_import_stream().
- Fixed socket_strerror.phpt
- Made php_set_sock_blocking return FAILURE on fcntl error.
- Made socket_set_block()/socket_set_nonblock() emit warning on error.
2011-03-22 00:44:23 +00:00

50 lines
1.4 KiB
PHP

--TEST--
socket_import_stream: Bad arguments
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
die('SKIP sockets extension not available.');
}
--FILE--
<?php
var_dump(socket_import_stream());
var_dump(socket_import_stream(1, 2));
var_dump(socket_import_stream(1));
var_dump(socket_import_stream(new stdclass));
var_dump(socket_import_stream(fopen(__FILE__, "rb")));
var_dump(socket_import_stream(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)));
$s = stream_socket_server("udp://127.0.0.1:58392", $errno, $errstr, STREAM_SERVER_BIND);
var_dump($s);
var_dump(fclose($s));
var_dump(socket_import_stream($s));
echo "Done.";
--EXPECTF--
Warning: socket_import_stream() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: socket_import_stream() expects exactly 1 parameter, 2 given in %s on line %d
NULL
Warning: socket_import_stream() expects parameter 1 to be resource, integer given in %s on line %d
NULL
Warning: socket_import_stream() expects parameter 1 to be resource, object given in %s on line %d
NULL
Warning: socket_import_stream(): cannot represent a stream of type STDIO as a Socket Descriptor in %s on line %d
bool(false)
Warning: socket_import_stream(): supplied resource is not a valid stream resource in %s on line %d
bool(false)
resource(%d) of type (stream)
bool(true)
Warning: socket_import_stream(): %d is not a valid stream resource in %s on line %d
bool(false)
Done.