diff options
author | Julien Pauli <jpauli@php.net> | 2015-12-24 14:08:59 +0100 |
---|---|---|
committer | Julien Pauli <jpauli@php.net> | 2015-12-24 14:08:59 +0100 |
commit | 048fb4b00f2e26c0d7e5ce3161722d631bc393fd (patch) | |
tree | 769b451fd795bbe8983b999d84bfe4040fc0583a /ext/sockets | |
parent | 3f09d301b5e4b50825b4560f0dd6673dbe616fc5 (diff) | |
parent | d73d9fecf6c7a4cf2a7443f1a3833c8fb6e30ea1 (diff) | |
download | php-git-048fb4b00f2e26c0d7e5ce3161722d631bc393fd.tar.gz |
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
Fixed and improved tests
test to function socket_getopt();
test to function socket_clear_error();;
test to function socket_shutdown();
test to function socket_send();
test to function gethostname ( void );
test to function DateTimeZone::getLocation();
test to function stream_get_transports();
test to function stream_get_wrappers();
test to function stream_socket_enable_crypto();
test to function stream_socket_get_name();
Create stream_socket_recvfrom.phpt
test to stream function set_file_buffer.phpt();
test to function PDO_getAvaliableDrivers;
test to misc. function connection_status();
test to function connection_aborted();
test to function memory_get_peak_usage();
Diffstat (limited to 'ext/sockets')
-rw-r--r-- | ext/sockets/tests/socket_clear_error.phpt | 28 | ||||
-rw-r--r-- | ext/sockets/tests/socket_getopt.phpt | 73 | ||||
-rw-r--r-- | ext/sockets/tests/socket_send.phpt | 50 | ||||
-rw-r--r-- | ext/sockets/tests/socket_shutdown.phpt | 54 |
4 files changed, 205 insertions, 0 deletions
diff --git a/ext/sockets/tests/socket_clear_error.phpt b/ext/sockets/tests/socket_clear_error.phpt new file mode 100644 index 0000000000..af9acaa9bf --- /dev/null +++ b/ext/sockets/tests/socket_clear_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +void socket_clear_error ([ resource $socket ] ) ; +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('SKIP sockets extension not available.'); +} +?> +--FILE-- +<?php +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, "127.0.0.1", 21248); +var_dump(socket_last_error($socket)); +socket_clear_error($socket); +var_dump(socket_last_error($socket)); +?> +--CLEAN-- +<?php +socket_close($socket); +unset($socket); +unset($socketConn); +?> +--EXPECTF-- +Warning: socket_connect(): unable to connect [%d]: Connection refused in %s on line %d +int(%d) +int(%d) diff --git a/ext/sockets/tests/socket_getopt.phpt b/ext/sockets/tests/socket_getopt.phpt new file mode 100644 index 0000000000..12c0aeb888 --- /dev/null +++ b/ext/sockets/tests/socket_getopt.phpt @@ -0,0 +1,73 @@ +--TEST-- +mixed socket_getopt( resource $socket , int $level , int $optname ) ; +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('skip sockets extension not available.'); +} +?> +--FILE-- +<?php +$domain = AF_INET; +$level = IPPROTO_IP; +$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err"); + +echo "Setting IP_MULTICAST_TTL\n"; +$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 9); +var_dump($r); +$r = socket_getopt($s, $level, IP_MULTICAST_TTL); +var_dump($r); +echo "\n"; + +echo "Setting IP_MULTICAST_LOOP\n"; +$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 0); +var_dump($r); +$r = socket_getopt($s, $level, IP_MULTICAST_LOOP); +var_dump($r); +$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 1); +var_dump($r); +$r = socket_getopt($s, $level, IP_MULTICAST_LOOP); +var_dump($r); +echo "\n"; + +echo "Setting IP_MULTICAST_IF\n"; +echo "interface 0:\n"; +$r = socket_set_option($s, $level, IP_MULTICAST_IF, 0); +var_dump($r); +$r = socket_getopt($s, $level, IP_MULTICAST_IF); +var_dump($r); +echo "interface 1:\n"; +$r = socket_set_option($s, $level, IP_MULTICAST_IF, 1); +var_dump($r); +$r = socket_getopt($s, $level, IP_MULTICAST_IF); +var_dump($r); +echo "\n"; +?> +--CLEAN-- +<?php +unset($domain); +unset($level); +socket_close($s); +unset($s); +unset($r"); +?> +--EXPECT-- +Setting IP_MULTICAST_TTL +bool(true) +int(9) + +Setting IP_MULTICAST_LOOP +bool(true) +int(0) +bool(true) +int(1) + +Setting IP_MULTICAST_IF +interface 0: +bool(true) +int(0) +interface 1: +bool(true) +int(1) diff --git a/ext/sockets/tests/socket_send.phpt b/ext/sockets/tests/socket_send.phpt new file mode 100644 index 0000000000..1411868c4b --- /dev/null +++ b/ext/sockets/tests/socket_send.phpt @@ -0,0 +1,50 @@ +--TEST-- +int socket_send ( resource $socket , string $buf , int $len , int $flags ); +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('SKIP sockets extension not available.'); +} +?> +--FILE-- +<?php +$port = 80; +$host = "yahoo.com"; +$stringSocket = "send_socket_to_connected_socket"; +$stringSocketLenght = strlen($stringSocket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); + +if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_OOB)===$stringSocketLenght){ + print("okey\n"); +} + +if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOR)===$stringSocketLenght){ + print("okey\n"); +} + +if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_EOF)===$stringSocketLenght){ + print("okey\n"); +} + +if(socket_send($socket, $stringSocket, $stringSocketLenght, MSG_DONTROUTE)===$stringSocketLenght){ + print("okey\n"); +} +?> +<?php +socket_close($socket); +unset($port); +unset($host); +unset($stringSocket); +unset($stringSocketLenght); +unset($socket); +unset($socketConn); +?> +--EXPECTF-- +okey +okey +okey +okey diff --git a/ext/sockets/tests/socket_shutdown.phpt b/ext/sockets/tests/socket_shutdown.phpt new file mode 100644 index 0000000000..09f5ac73fc --- /dev/null +++ b/ext/sockets/tests/socket_shutdown.phpt @@ -0,0 +1,54 @@ +--TEST-- +bool socket_shutdown ( resource $socket [, int $how = 2 ] ) ; +--CREDITS-- +marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br +--SKIPIF-- +<?php +if (!extension_loaded('sockets')) { + die('SKIP sockets extension not available.'); +} +?> +--FILE-- +<?php +$host = "yahoo.com"; +$port = 80; + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,0)); +socket_close($socket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,1)); +socket_close($socket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,2)); +socket_close($socket); + +$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); +var_dump(socket_shutdown($socket,0)); + +$socketConn = socket_connect($socket, $host, $port); +var_dump(socket_shutdown($socket,-1)); +socket_close($socket); +?> +--CLEAN-- +<?php +unset($host); +unset($port); +unset($socket); +unset($socketConn); +?> +--EXPECTF-- +bool(true) +bool(true) +bool(true) + +Warning: socket_shutdown(): unable to shutdown socket [%d]: Transport endpoint is not connected in %s on line %d +bool(false) + +Warning: socket_shutdown(): unable to shutdown socket [%d]: Invalid argument in %s on line %d +bool(false) |