felipe          Sun May 17 18:08:09 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/sockets/tests  socket_accept-wrongparams.phpt 
                                socket_create_listen-nobind.phpt 
                                socket_create_listen-wrongparams.phpt 
                                socket_create_listen.phpt 
                                socket_create_pair-wrongparams.phpt 
                                socket_create_pair.phpt 
                                socket_listen-wrongparams.phpt 
                                socket_select-wrongparams-1.phpt 
                                socket_select-wrongparams-2.phpt 
                                socket_select-wrongparams-3.phpt 
                                socket_select-wrongparams-4.phpt 
                                socket_select.phpt 
                                socket_sentto_recvfrom_ipv4_udp.phpt 
                                socket_sentto_recvfrom_ipv6_udp.phpt 
                                socket_sentto_recvfrom_unix.phpt 
                                socket_set_block-retval.phpt 
                                socket_set_block-wrongparams.phpt 
                                socket_set_nonblock-retval.phpt 
                                socket_set_nonblock-wrongparams.phpt 
                                socket_set_option_error_socket_option.phpt 
                                socket_set_option_rcvtimeo.phpt 
                                socket_set_option_seolinger.phpt 
                                socket_set_option_sndtimeo.phpt 
  Log:
  - New tests (testfest BerlinUG)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_accept-wrongparams.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_accept-wrongparams.phpt
+++ php-src/ext/sockets/tests/socket_accept-wrongparams.phpt
--TEST--
Test parameter handling in socket_accept()
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
var_dump(socket_accept(null));
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009 
--EXPECTF--
Warning: socket_accept() expects parameter 1 to be resource, null given in %s 
on line %d
NULL

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_create_listen-nobind.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_create_listen-nobind.phpt
+++ php-src/ext/sockets/tests/socket_create_listen-nobind.phpt
--TEST--
Test if socket_create_listen() returns false, when it cannot bind to the port.
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
$filename = dirname(__FILE__) . '/006_root_check.tmp';
$fp = fopen($filename, 'w');
fclose($fp);
if (fileowner($filename) == 0) {
    unlink ($filename);
    die('SKIP Test cannot be run as root.');
}
--FILE--
<?php
$sock = socket_create_listen(80);
--EXPECTF--
Warning: socket_create_listen(): unable to bind to given address [13]: 
Permission denied in %s on line %d
--CLEAN--
<?php
unlink(dirname(__FILE__) . '/006_root_check.tmp');
--CREDITS--
Till Klampaeckel, t...@php.net
PHP Testfest Berlin 2009-05-09
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_create_listen-wrongparams.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_create_listen-wrongparams.phpt
+++ php-src/ext/sockets/tests/socket_create_listen-wrongparams.phpt
--TEST--
Test if socket_create_listen throws E_WARNING with wrong parameters.
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sock1 = socket_create_listen(array());
$sock2 = socket_create_listen(31337, array());
--EXPECTF--
Warning: socket_create_listen() expects parameter 1 to be long, array given in 
%s on line %d

Warning: socket_create_listen() expects parameter 2 to be long, array given in 
%s on line %d
--CREDITS--
Till Klampaeckel, t...@php.net
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_create_listen.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_create_listen.phpt
+++ php-src/ext/sockets/tests/socket_create_listen.phpt
--TEST--
Test if socket binds on 31337
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sock = socket_create_listen(31337);
socket_getsockname($sock, $addr, $port); 
var_dump($addr, $port);
--EXPECT--
string(7) "0.0.0.0"
int(31337)
--CREDITS--
Till Klampaeckel, t...@php.net
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_create_pair-wrongparams.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_create_pair-wrongparams.phpt
+++ php-src/ext/sockets/tests/socket_create_pair-wrongparams.phpt
--TEST--
Test parameter handling in socket_create_pair()
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
var_dump(socket_create_pair(AF_INET, null, null));

$domain = 'unknown';
var_dump(socket_create_pair($domain, SOCK_STREAM, 0, $sockets));

var_dump(socket_create_pair(AF_INET, null, null, $sockets));

var_dump(socket_create_pair(31337, null, null, $sockets));

var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
--EXPECTF--
Warning: socket_create_pair() expects exactly 4 parameters, 3 given in %s on 
line %d
NULL

Warning: socket_create_pair() expects parameter 1 to be long, 
%unicode_string_optional% given in %s on line %d
NULL

Warning: socket_create_pair(): unable to create socket pair [94]: Socket type 
not supported in %s on line %d
bool(false)

Warning: socket_create_pair(): invalid socket domain [31337] specified for 
argument 1, assuming AF_INET in %s on line %d

Warning: socket_create_pair(): unable to create socket pair [94]: Socket type 
not supported in %s on line %d
bool(false)

Warning: socket_create_pair(): invalid socket type [31337] specified for 
argument 2, assuming SOCK_STREAM in %s on line %d

Warning: socket_create_pair(): unable to create socket pair [95]: Operation not 
supported in %s on line %d
bool(false)
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_create_pair.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_create_pair.phpt
+++ php-src/ext/sockets/tests/socket_create_pair.phpt
--TEST--
Test for socket_create_pair()
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sockets = array();
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
    $domain = AF_INET;
} else {
    $domain = AF_UNIX;
}
socket_create_pair($domain, SOCK_STREAM, 0, $sockets);
var_dump($sockets);
--EXPECT--
array(2) {
  [0]=>
  resource(4) of type (Socket)
  [1]=>
  resource(5) of type (Socket)
}

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_listen-wrongparams.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_listen-wrongparams.phpt
+++ php-src/ext/sockets/tests/socket_listen-wrongparams.phpt
--TEST--
Test parameter handling in socket_listen().
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
var_dump(socket_listen(null));
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0); 
var_dump(socket_listen($socket));
--EXPECTF--
Warning: socket_listen() expects parameter 1 to be resource, null given in %s 
on line %d
NULL

Warning: socket_listen(): unable to listen on socket [%d]: Invalid argument in 
%s on line %d
bool(false)
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_select-wrongparams-1.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_select-wrongparams-1.phpt
+++ php-src/ext/sockets/tests/socket_select-wrongparams-1.phpt
--TEST--
Test parameter handling in socket_select().
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sockets = array();
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
    $domain = AF_INET;
} else {
    $domain = AF_UNIX;
}
socket_create_pair($domain, SOCK_STREAM, 0, $sockets);

$write  = null;
$except = null;
$time   = -1;
var_dump(socket_select($sockets, $write, $except, $time));
--EXPECTF--
Warning: socket_select(): unable to select [%d]: Invalid argument in %s on line 
%d
bool(false)
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_select-wrongparams-2.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_select-wrongparams-2.phpt
+++ php-src/ext/sockets/tests/socket_select-wrongparams-2.phpt
--TEST--
Test parameter handling in socket_select().
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sockets = null;
$write   = null;
$except  = null;
$time    = 0;
var_dump(socket_select($sockets, $write, $except, $time));
socket_select($sockets, $write, $except);
--EXPECTF--
Warning: socket_select(): no resource arrays were passed to select in %s on 
line %d
bool(false)

Warning: socket_select() expects at least 4 parameters, 3 given in %s on line %d
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_select-wrongparams-3.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_select-wrongparams-3.phpt
+++ php-src/ext/sockets/tests/socket_select-wrongparams-3.phpt
--TEST--
Test parameter handling in socket_select().
--DESCRIPTION--
Time must be long, otherwise it's casted.
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sockets = array();
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
    $domain = AF_INET;
} else {
    $domain = AF_UNIX;
}
socket_create_pair($domain, SOCK_STREAM, 0, $sockets);

$write  = null;
$except = null;
$time   = array();
var_dump(socket_select($sockets, $write, $except, $time));
--EXPECT--
int(0)
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_select-wrongparams-4.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_select-wrongparams-4.phpt
+++ php-src/ext/sockets/tests/socket_select-wrongparams-4.phpt
--TEST--
Test parameter handling in socket_select().
--DESCRIPTION--
usec > 999999
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sockets = array();
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
    $domain = AF_INET;
} else {
    $domain = AF_UNIX;
}
socket_create_pair($domain, SOCK_STREAM, 0, $sockets);

$write  = null;
$except = null;
$time   = 0;
$usec   = 2000000;
var_dump(socket_select($sockets, $write, $except, $time, $usec));
--EXPECT--
int(0)
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_select.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_select.phpt
+++ php-src/ext/sockets/tests/socket_select.phpt
--TEST--
Test parameter handling in socket_select().
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$sockets = array();
if (strtolower(substr(PHP_OS, 0, 3)) == 'win') {
    $domain = AF_INET;
} else {
    $domain = AF_UNIX;
}
socket_create_pair($domain, SOCK_STREAM, 0, $sockets);

$write  = null;
$except = null;
var_dump(socket_select($sockets, $write, $except, 0));
--EXPECT--
int(0)
--CREDITS--
Till Klampaeckel, t...@php.net
Berlin TestFest 2009

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt
+++ php-src/ext/sockets/tests/socket_sentto_recvfrom_ipv4_udp.phpt
--TEST--
Test if socket_recvfrom() receives data sent by socket_sendto() via IPv4 UDP
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
    $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
    if (!$socket) {
        die('Unable to create AF_INET socket');
    }
    if (!socket_set_nonblock($socket)) {
        die('Unable to set nonblocking mode for socket');
    }
    socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning
    $address = '127.0.0.1';
    socket_sendto($socket, '', 1, 0, $address); // cause warning
    if (!socket_bind($socket, $address, 1223)) {
        die("Unable to bind to $address:1223");
    }

    $msg = "Ping!";
    $len = strlen($msg);
    $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address, 1223);
    if ($bytes_sent == -1) {
        die('An error occured while sending to the socket');
    } else if ($bytes_sent != $len) {
        die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' 
bytes expected');
    }

    $from = "";
    $port = 0;
    socket_recvfrom($socket, $buf, 12, 0); // cause warning
    socket_recvfrom($socket, $buf, 12, 0, $from); // cause warning
    $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from, $port);
    if ($bytes_received == -1) {
        die('An error occured while receiving from the socket');
    } else if ($bytes_received != $len) {
        die($bytes_received . ' bytes have been received instead of the ' . 
$len . ' bytes expected');
    }
    echo "Received $buf from remote address $from and remote port $port" . 
PHP_EOL;

    socket_close($socket);
--EXPECTF--
Warning: socket_recvfrom(): unable to recvfrom [11]: Resource temporarily 
unavailable in %s on line %d

Warning: Wrong parameter count for socket_sendto() in %s on line %d

Warning: socket_recvfrom() expects at least 5 parameters, 4 given in %s on line 
%d

Warning: Wrong parameter count for socket_recvfrom() in %s on line %d
Received Ping! from remote address 127.0.0.1 and remote port 1223
--CREDITS--
Falko Menge <mail at falko-menge dot de>
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt
+++ php-src/ext/sockets/tests/socket_sentto_recvfrom_ipv6_udp.phpt
--TEST--
Test if socket_recvfrom() receives data sent by socket_sendto() via IPv6 UDP
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
    $socket = socket_create(AF_INET6, SOCK_DGRAM, SOL_UDP);
    if (!$socket) {
        die('Unable to create AF_INET6 socket');
    }
    if (!socket_set_nonblock($socket)) {
        die('Unable to set nonblocking mode for socket');
    }
    socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning
    $address = '::1';
    socket_sendto($socket, '', 1, 0, $address); // cause warning
    if (!socket_bind($socket, $address, 1223)) {
        die("Unable to bind to $address:1223");
    }

    $msg = "Ping!";
    $len = strlen($msg);
    $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address, 1223);
    if ($bytes_sent == -1) {
        die('An error occured while sending to the socket');
    } else if ($bytes_sent != $len) {
        die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' 
bytes expected');
    }

    $from = "";
    $port = 0;
    socket_recvfrom($socket, $buf, 12, 0); // cause warning
    socket_recvfrom($socket, $buf, 12, 0, $from); // cause warning
    $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from, $port);
    if ($bytes_received == -1) {
        die('An error occured while receiving from the socket');
    } else if ($bytes_received != $len) {
        die($bytes_received . ' bytes have been received instead of the ' . 
$len . ' bytes expected');
    }
    echo "Received $buf from remote address $from and remote port $port" . 
PHP_EOL;

    socket_close($socket);
--EXPECTF--
Warning: socket_recvfrom(): unable to recvfrom [11]: Resource temporarily 
unavailable in %s on line %d

Warning: Wrong parameter count for socket_sendto() in %s on line %d

Warning: socket_recvfrom() expects at least 5 parameters, 4 given in %s on line 
%d

Warning: Wrong parameter count for socket_recvfrom() in %s on line %d
Received Ping! from remote address ::1 and remote port 1223
--CREDITS--
Falko Menge <mail at falko-menge dot de>
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt
+++ php-src/ext/sockets/tests/socket_sentto_recvfrom_unix.phpt
--TEST--
Test if socket_recvfrom() receives data sent by socket_sendto() through a Unix 
domain socket
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
    $socket = socket_create(AF_UNIX, SOCK_DGRAM, SOL_UDP); // cause warning
    $socket = socket_create(AF_UNIX, SOCK_DGRAM, 0);
    if (!$socket) {
        die('Unable to create AF_UNIX socket');
    }
    if (!socket_set_nonblock($socket)) {
        die('Unable to set nonblocking mode for socket');
    }
    socket_recvfrom($socket, $buf, 12, 0, $from, $port); // cause warning
    $address = sprintf("/tmp/%s.sock", uniqid());
    if (!socket_bind($socket, $address)) {
        die("Unable to bind to $address");
    }

    $msg = "Ping!";
    $len = strlen($msg);
    $bytes_sent = socket_sendto($socket, $msg, $len, 0); // cause warning
    $bytes_sent = socket_sendto($socket, $msg, $len, 0, $address);
    if ($bytes_sent == -1) {
        die('An error occured while sending to the socket');
    } else if ($bytes_sent != $len) {
        die($bytes_sent . ' bytes have been sent instead of the ' . $len . ' 
bytes expected');
    }

    $from = "";
    var_dump(socket_recvfrom($socket, $buf, 0, 0, $from)); // expect false
    $bytes_received = socket_recvfrom($socket, $buf, 12, 0, $from);
    if ($bytes_received == -1) {
        die('An error occured while receiving from the socket');
    } else if ($bytes_received != $len) {
        die($bytes_received . ' bytes have been received instead of the ' . 
$len . ' bytes expected');
    }
    echo "Received $buf";

    socket_close($socket);
--EXPECTF--
Warning: socket_create(): Unable to create socket [93]: Protocol not supported 
in %s on line %d

Warning: socket_recvfrom(): unable to recvfrom [11]: Resource temporarily 
unavailable in %s on line %d

Warning: socket_sendto() expects at least 5 parameters, 4 given in %s on line %d
bool(false)
Received Ping!
--CREDITS--
Falko Menge <mail at falko-menge dot de>
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_block-retval.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_block-retval.phpt
+++ php-src/ext/sockets/tests/socket_set_block-retval.phpt
--TEST--
Test socket_set_block return values
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
?>
--FILE--
<?php

$socket = socket_create_listen(31337);
var_dump(socket_set_block($socket));
socket_close($socket);

$socket2 = socket_create_listen(31338);
socket_close($socket2);
var_dump(socket_set_block($socket2));

?>
--EXPECTF--
bool(true)

Warning: socket_set_block(): %d is not a valid Socket resource in %s on line %d
bool(false)
--CREDITS--
Robin Mehner, ro...@coding-robin.de
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_block-wrongparams.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_block-wrongparams.phpt
+++ php-src/ext/sockets/tests/socket_set_block-wrongparams.phpt
--TEST--
Test if socket_set_block throws E_WARNING with wrong parameters.
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
?>
--FILE--
<?php
socket_set_block(array());
?>
--EXPECTF--
Warning: socket_set_block() expects parameter 1 to be resource, array given in 
%s on line %d
--CREDITS--
Robin Mehner, ro...@coding-robin.de
PHP Testfest Berlin 2009-05-09


http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_nonblock-retval.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_nonblock-retval.phpt
+++ php-src/ext/sockets/tests/socket_set_nonblock-retval.phpt
--TEST--
Test socket_set_nonblock return values
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
?>
--FILE--
<?php

$socket = socket_create_listen(31337);
var_dump(socket_set_nonblock($socket));
socket_close($socket);

$socket2 = socket_create_listen(31338);
socket_close($socket2);
var_dump(socket_set_nonblock($socket2));

?>
--EXPECTF--
bool(true)

Warning: socket_set_nonblock(): %d is not a valid Socket resource in %s on line 
%d
bool(false)
--CREDITS--
Robin Mehner, ro...@coding-robin.de
PHP Testfest Berlin 2009-05-09

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_nonblock-wrongparams.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_nonblock-wrongparams.phpt
+++ php-src/ext/sockets/tests/socket_set_nonblock-wrongparams.phpt
--TEST--
Test if socket_set_nonblock throws E_WARNING with wrong parameters.
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
    die('SKIP The sockets extension is not loaded.');
}
--FILE--
<?php
$socket = socket_set_nonblock(array());
?>
--EXPECTF--
Warning: socket_set_nonblock() expects parameter 1 to be resource, array given 
in %s on line %d

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_option_error_socket_option.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_option_error_socket_option.phpt
+++ php-src/ext/sockets/tests/socket_set_option_error_socket_option.phpt
--TEST--
Test if socket_set_option() returns 'unable to set socket option' failure for 
invalid options
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
        die('SKIP sockets extension not available.');
}
$filename = dirname(__FILE__) . '/006_root_check.tmp';
$fp = fopen($filename, 'w');
fclose($fp);
if (fileowner($filename) == 0) {
    unlink ($filename);
    die('SKIP Test cannot be run as root.');
}
?>
--FILE--
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {
        die('Unable to create AF_INET socket [socket]');
}

socket_set_option( $socket, SOL_SOCKET, 1, 1);
socket_close($socket);
?>
--CLEAN--
<?php
unlink(dirname(__FILE__) . '/006_root_check.tmp');
--EXPECTF--
Warning: socket_set_option(): unable to set socket option [%d]: Permission 
denied in %s on line %d
--CREDITS--
Moritz Neuhaeuser, i...@xcompile.net
PHP Testfest Berlin 2009-05-10

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_option_rcvtimeo.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
+++ php-src/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
--TEST--
Test if socket_set_option() works, option:SO_RCVTIMEO
--DESCRIPTION---
-wrong params 
-set/get params comparison 
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
        die('SKIP sockets extension not available.');
}
?>
--FILE--
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {
        die('Unable to create AF_INET socket [socket]');
}
socket_set_block($socket);

//wrong params
$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, array());

//set/get comparison
$options = array("sec" => 1, "usec" => 0);
$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, $options);
$retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_RCVTIMEO);

var_dump($retval_2);
var_dump($retval_3 === $options);
socket_close($socket);
?>

--EXPECTF--
Warning: socket_set_option(): no key "sec" passed in optval in %s on line %d
bool(true)
bool(true)
--CREDITS--
Moritz Neuhaeuser, i...@xcompile.net
PHP Testfest Berlin 2009-05-10

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_option_seolinger.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_option_seolinger.phpt
+++ php-src/ext/sockets/tests/socket_set_option_seolinger.phpt
--TEST--
Test if socket_set_option() works, option:SO_SEOLINGER
--DESCRIPTION---
-wrong params 
-set/get params comparison 
-l_linger not given
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
        die('SKIP sockets extension not available.');
}
?>
--FILE--
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

if (!$socket) {
        die('Unable to create AF_INET socket [socket]');
}
// wrong params
$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, array());

// set/get comparison
$options = array("l_onoff" => 1, "l_linger" => 1);
$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options);
$retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_LINGER);

//l_linger not given
$options_2 = array("l_onoff" => 1);
var_dump(socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_2));

var_dump($retval_2);
var_dump($retval_3 === $options);

socket_close($socket);
?>

--EXPECTF--
Warning: socket_set_option(): no key "l_onoff" passed in optval in %s on line %d

Warning: socket_set_option(): no key "l_linger" passed in optval in %s on line 
%d
bool(false)
bool(true)
bool(true)
--CREDITS--
Moritz Neuhaeuser, i...@xcompile.net
PHP Testfest Berlin 2009-05-10

http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/tests/socket_set_option_sndtimeo.phpt?view=markup&rev=1.1
Index: php-src/ext/sockets/tests/socket_set_option_sndtimeo.phpt
+++ php-src/ext/sockets/tests/socket_set_option_sndtimeo.phpt
--TEST--
Test if socket_set_option() works, option:SO_SNDTIMEO
--DESCRIPTION---
-wrong params 
-set/get params comparison 
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
        die('SKIP sockets extension not available.');
}
?>
--FILE--
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if (!$socket) {
        die('Unable to create AF_INET socket [socket]');
}
socket_set_block($socket);

//wrong params
$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, array());

//set/get comparison
$options = array("sec" => 1, "usec" => 0);
$retval_2 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, $options);
$retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_SNDTIMEO);

var_dump($retval_2);
var_dump($retval_3 === $options);
socket_close($socket);
?>

--EXPECTF--
Warning: socket_set_option(): no key "sec" passed in optval in %s on line %d
bool(true)
bool(true)
--CREDITS--
Moritz Neuhaeuser, i...@xcompile.net
PHP Testfest Berlin 2009-05-10

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to