Skip to content

Commit b9fbbcc

Browse files
committed
Use different error condition in socket test
The previously used error does not occur on FreeBSD and instead causes the operation to time out. Also clean up the test a bit. And make sure it actually tests something -- the point is that socket_last_error() should be 0 after socket_clear_error(). It's kind of pointless if the test uses a wildcard for the final result instead.
1 parent 2fabe27 commit b9fbbcc

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

ext/sockets/tests/socket_clear_error.phpt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@ marcosptf - <[email protected]> - #phparty7 - @phpsp - novatec/2015 - sao p
77
if (!extension_loaded('sockets')) {
88
die('SKIP sockets extension not available.');
99
}
10-
if(substr(PHP_OS, 0, 3) == 'WIN' ) {
11-
die('skip windows only test');
10+
if (substr(PHP_OS, 0, 3) == 'WIN' ) {
11+
die('skip non-windows only test');
1212
}
1313
?>
1414
--FILE--
1515
<?php
1616
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
17-
$socketConn = socket_connect($socket, "127.0.0.1", 21248);
17+
socket_set_option($socket, -1, -1, -1);
1818
var_dump(socket_last_error($socket));
1919
socket_clear_error($socket);
2020
var_dump(socket_last_error($socket));
2121
?>
22-
--CLEAN--
23-
<?php
24-
socket_close($socket);
25-
unset($socket);
26-
unset($socketConn);
27-
?>
2822
--EXPECTF--
29-
Warning: socket_connect(): unable to connect [%d]: Connection refused in %s on line %d
30-
int(%d)
23+
Warning: socket_set_option(): Unable to set socket option [%s]: %s in %s on line %d
3124
int(%d)
25+
int(0)

0 commit comments

Comments
 (0)