Add test socket_setopt() basic functionality

Rodrigo Prado de Jesus royopa@gmail.com
User Group: PHPSP #PHPTestFestBrasil
---------------------------------------------------------------
The function was not coveraged yet
sockets	Function	socket_setopt	no
http://gcov.php.net/viewer.php?version=PHP_HEAD&func=tested_functions
This commit is contained in:
Rodrigo Prado 2017-11-16 20:32:23 -02:00 committed by Peter Kokot
parent e1cc714445
commit b86d7738fb

View File

@ -0,0 +1,31 @@
--TEST--
Test socket_setopt() basic functionality
--CREDITS--
Rodrigo Prado de Jesus <royopa [at] gmail [dot] com>
User Group: PHPSP #PHPTestFestBrasil
--SKIPIF--
<?php
if (!extension_loaded('sockets')) {
die('skip. Sockets extension is 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);
//set/get comparison
$options = array("sec" => 1, "usec" => 0);
$retval_1 = socket_setopt( $socket, SOL_SOCKET, SO_SNDTIMEO, $options);
$retval_2 = socket_getopt( $socket, SOL_SOCKET, SO_SNDTIMEO);
var_dump($retval_1);
var_dump($retval_2 === $options);
socket_close($socket);
?>
--EXPECT--
bool(true)
bool(true)