Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/sockets/tests/gh16267.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ sockets
var_dump(socket_strerror(-2147483648));
try {
socket_strerror(2147483648);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
string(%d) "%S"
socket_strerror(): Argument #1 ($error_code) must be between %i and %d
ValueError: socket_strerror(): Argument #1 ($error_code) must be between %i and %d
1 change: 0 additions & 1 deletion ext/sockets/tests/gh20532.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ var_dump(socket_addrinfo_lookup("example.com", "http", ['ai_socktype' => SOCK_RA
bool(true)
bool(true)
bool(true)

12 changes: 6 additions & 6 deletions ext/sockets/tests/mcast_ipv4_send_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ echo "Setting IP_MULTICAST_TTL with 256\n";
try {
$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 256);
var_dump($r);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
var_dump($r);
Expand All @@ -61,8 +61,8 @@ echo "Setting IP_MULTICAST_TTL with -1\n";
try {
$r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1);
var_dump($r);
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
var_dump($r);
Expand All @@ -78,13 +78,13 @@ bool(true)
int(0)

Setting IP_MULTICAST_TTL with 256
socket_set_option(): Argument #4 ($value) must be between 0 and 255
ValueError: socket_set_option(): Argument #4 ($value) must be between 0 and 255
int(1)

Setting IP_MULTICAST_TTL with "254"
bool(true)
int(254)

Setting IP_MULTICAST_TTL with -1
socket_set_option(): Argument #4 ($value) must be between 0 and 255
ValueError: socket_set_option(): Argument #4 ($value) must be between 0 and 255
int(254)
6 changes: 3 additions & 3 deletions ext/sockets/tests/mcast_sockettype_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ try {
"group" => '127.0.0.1',
"interface" => "lo",
));
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
IP address used in the context of an unexpected type of socket
ValueError: IP address used in the context of an unexpected type of socket
6 changes: 3 additions & 3 deletions ext/sockets/tests/socket_addrinfo_lookup.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ try {
'invalid' => null,
));
var_dump($addrinfo[0]);
} catch (\ValueError $e) {
echo $e->getMessage(), \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family"
ValueError: socket_addrinfo_lookup(): Argument #3 ($hints) must only contain array keys "ai_flags", "ai_socktype", "ai_protocol", or "ai_family"
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_bind_invalid_port.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ sockets

try {
socket_bind($s_c, '0.0.0.0', -1);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
socket_bind($s_c, '0.0.0.0', 65536);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
socket_bind(): Argument #3 ($port) must be between 0 and 65535
socket_bind(): Argument #3 ($port) must be between 0 and 65535
ValueError: socket_bind(): Argument #3 ($port) must be between 0 and 65535
ValueError: socket_bind(): Argument #3 ($port) must be between 0 and 65535
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_cmsg_udp_segment.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ $src = socket_create(AF_UNIX, SOCK_DGRAM, 0);

try {
socket_setopt($src, SOL_UDP, UDP_SEGMENT, -1);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
socket_setopt($src, SOL_UDP, UDP_SEGMENT, 65536);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
socket_setopt(): Argument #4 ($value) must be between 0 and 65535
socket_setopt(): Argument #4 ($value) must be between 0 and 65535
ValueError: socket_setopt(): Argument #4 ($value) must be between 0 and 65535
ValueError: socket_setopt(): Argument #4 ($value) must be between 0 and 65535
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_connect_params.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ socket_getsockname($s_c, $addr, $port);
// wrong parameter count
try {
socket_connect($s_c);
} catch (\ArgumentCountError $e) {
echo $e->getMessage() . \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
socket_connect($s_c, '0.0.0.0');
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$s_w = socket_connect($s_c, '0.0.0.0', $port);

socket_close($s_c);
?>
--EXPECTF--
socket_connect() expects at least 2 arguments, 1 given
socket_connect(): Argument #3 ($port) cannot be null when the socket type is AF_INET
ArgumentCountError: socket_connect() expects at least 2 arguments, 1 given
ValueError: socket_connect(): Argument #3 ($port) cannot be null when the socket type is AF_INET

Warning: socket_connect(): unable to connect [%i]: %a in %s on line %d
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_create_listen_invalid_port.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ var_dump(socket_create_listen(0));

try {
socket_create_listen(-1);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
socket_create_listen(65536);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
object(Socket)#1 (0) {
}
socket_create_listen(): Argument #1 ($port) must be between 0 and 65535
socket_create_listen(): Argument #1 ($port) must be between 0 and 65535
ValueError: socket_create_listen(): Argument #1 ($port) must be between 0 and 65535
ValueError: socket_create_listen(): Argument #1 ($port) must be between 0 and 65535
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_create_pair-wrongparams.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ var_dump(socket_create_pair(AF_INET, 0, 0, $sockets));

try {
var_dump(socket_create_pair(31337, 0, 0, $sockets));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECTF--
Warning: socket_create_pair(): Unable to create socket pair [%d]: %s %r(not supported|wrong type for socket)%r in %s on line %d
bool(false)
socket_create_pair(): Argument #1 ($domain) must be one of AF_UNIX, AF_INET6, or AF_INET
socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
ValueError: socket_create_pair(): Argument #1 ($domain) must be one of AF_UNIX, AF_INET6, or AF_INET
ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
--CREDITS--
Till Klampaeckel, till@php.net
Berlin TestFest 2009
18 changes: 9 additions & 9 deletions ext/sockets/tests/socket_create_pair_sockexec.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ if (!defined('SOCK_NONBLOCK')) die("skip SOCK_NONBLOCK");
$sockets = array();
try {
socket_create_pair(AF_UNIX, 11 | SOCK_CLOEXEC, 0, $sockets);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
socket_create_pair(AF_UNIX, 11 | SOCK_NONBLOCK, 0, $sockets);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
socket_create_pair(AF_UNIX, 11 | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, $sockets);
} catch (\ValueError $e) {
echo $e->getMessage() . PHP_EOL;
} catch (\Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump(socket_create_pair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, $sockets));
?>
--EXPECTF--
socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
ValueError: socket_create_pair(): Argument #2 ($type) must be one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM%A
bool(true)
18 changes: 9 additions & 9 deletions ext/sockets/tests/socket_export_stream-2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ sockets

try {
socket_export_stream(fopen(__FILE__, "rb"));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
socket_export_stream(stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
var_dump($s);
socket_close($s);

try {
var_dump(socket_export_stream($s));
} catch (Error $e) {
echo $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Done.";
?>
--EXPECTF--
socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given
socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given
TypeError: socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given
TypeError: socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given
object(Socket)#%d (0) {
}
socket_export_stream(): Argument #1 ($socket) has already been closed
Error: socket_export_stream(): Argument #1 ($socket) has already been closed
Done.
12 changes: 6 additions & 6 deletions ext/sockets/tests/socket_export_stream-4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ function test($stream, $sock) {
echo "stream_set_blocking ";
try {
print_r(stream_set_blocking($stream, false));
} catch (Error $e) {
echo get_class($e), ": ", $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "\n";
}
if ($sock !== null) {
echo "socket_set_block ";
try {
print_r(socket_set_block($sock));
} catch (Error $e) {
echo get_class($e), ": ", $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "\n";
echo "socket_get_option ";
try {
// Solaris uses different numeric values for SOCK_* constants
$opt = socket_get_option($sock, SOL_SOCKET, SO_TYPE);
print_r($opt === SOCK_DGRAM ? "DGRAM" : $opt);
} catch (Error $e) {
echo get_class($e), ": ", $e->getMessage(), "\n";
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "\n";
}
Expand Down
Loading
Loading