PATH:
opt
/
alt
/
tests
/
alt-php83-pecl-zmq_1.1.3-1.84f0720.el8
/
tests
--TEST-- Test setting socket options --SKIPIF-- <?php require_once(dirname(__FILE__) . '/skipif.inc'); if (!defined('ZMQ::LIBZMQ_VERSION_MAJOR') || ZMQ::LIBZMQ_VERSION_MAJOR < 2) { die ("skip This test is for PHP7 and libzmq version 2.x and up"); } ?> --FILE-- <?php $tested = 0; $removedVersion = 3; /* socket option is marked mode="rw" type=uint64 php_type=int */ if (defined ("ZMQ::SOCKOPT_HWM") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_HWM, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_HWM); if ($socket->getSockOpt(ZMQ::SOCKOPT_HWM) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_HWM: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = 3; /* socket option is marked mode="rw" type=int64 php_type=int */ if (defined ("ZMQ::SOCKOPT_SWAP") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_SWAP, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SWAP); if ($socket->getSockOpt(ZMQ::SOCKOPT_SWAP) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_SWAP: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=uint64 php_type=int */ if (defined ("ZMQ::SOCKOPT_AFFINITY") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_AFFINITY, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_AFFINITY); if ($socket->getSockOpt(ZMQ::SOCKOPT_AFFINITY) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_AFFINITY: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=string php_type=string */ if (defined ("ZMQ::SOCKOPT_IDENTITY") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = "test"; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_DEALER); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_IDENTITY, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_IDENTITY); if ($socket->getSockOpt(ZMQ::SOCKOPT_IDENTITY) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_IDENTITY: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int64 php_type=int */ if (defined ("ZMQ::SOCKOPT_RATE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RATE, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RATE); if ($socket->getSockOpt(ZMQ::SOCKOPT_RATE) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RATE: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int64 php_type=int */ if (defined ("ZMQ::SOCKOPT_RECOVERY_IVL") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL); if ($socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RECOVERY_IVL: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = 3; /* socket option is marked mode="rw" type=int64 php_type=int */ if (defined ("ZMQ::SOCKOPT_RECOVERY_IVL_MSEC") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL_MSEC, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL_MSEC); if ($socket->getSockOpt(ZMQ::SOCKOPT_RECOVERY_IVL_MSEC) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RECOVERY_IVL_MSEC: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = 3; /* socket option is marked mode="rw" type=int64 php_type=int */ if (defined ("ZMQ::SOCKOPT_MCAST_LOOP") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_MCAST_LOOP, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_MCAST_LOOP); if ($socket->getSockOpt(ZMQ::SOCKOPT_MCAST_LOOP) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_MCAST_LOOP: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_RCVTIMEO") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RCVTIMEO, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVTIMEO); if ($socket->getSockOpt(ZMQ::SOCKOPT_RCVTIMEO) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RCVTIMEO: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_SNDTIMEO") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_SNDTIMEO, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SNDTIMEO); if ($socket->getSockOpt(ZMQ::SOCKOPT_SNDTIMEO) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_SNDTIMEO: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=uint64 php_type=int */ if (defined ("ZMQ::SOCKOPT_SNDBUF") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_SNDBUF, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_SNDBUF); if ($socket->getSockOpt(ZMQ::SOCKOPT_SNDBUF) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_SNDBUF: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=uint64 php_type=int */ if (defined ("ZMQ::SOCKOPT_RCVBUF") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RCVBUF, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVBUF); if ($socket->getSockOpt(ZMQ::SOCKOPT_RCVBUF) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RCVBUF: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_LINGER") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_LINGER, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_LINGER); if ($socket->getSockOpt(ZMQ::SOCKOPT_LINGER) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_LINGER: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_RECONNECT_IVL") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL); if ($socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RECONNECT_IVL: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_RECONNECT_IVL_MAX") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL_MAX, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL_MAX); if ($socket->getSockOpt(ZMQ::SOCKOPT_RECONNECT_IVL_MAX) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_RECONNECT_IVL_MAX: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="rw" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_BACKLOG") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-write $socket->setSockOpt(ZMQ::SOCKOPT_BACKLOG, $test_value); $retval = $socket->getSockOpt(ZMQ::SOCKOPT_BACKLOG); if ($socket->getSockOpt(ZMQ::SOCKOPT_BACKLOG) !== $test_value) { echo "Failed to set ZMQ::SOCKOPT_BACKLOG: expected=[$test_value] actual=[$retval]" . PHP_EOL; } $tested++; } $removedVersion = false; /* socket option is marked mode="w" type=string php_type=string */ if (defined ("ZMQ::SOCKOPT_SUBSCRIBE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = "test"; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test write-only $socket->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, $test_value); $tested++; try { $socket->getSockOpt(ZMQ::SOCKOPT_SUBSCRIBE); echo "Should not be able to get ZMQ::SOCKOPT_SUBSCRIBE" . PHP_EOL; } catch (ZMQSocketException $e) {} } $removedVersion = false; /* socket option is marked mode="w" type=string php_type=string */ if (defined ("ZMQ::SOCKOPT_UNSUBSCRIBE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = "test"; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test write-only $socket->setSockOpt(ZMQ::SOCKOPT_UNSUBSCRIBE, $test_value); $tested++; try { $socket->getSockOpt(ZMQ::SOCKOPT_UNSUBSCRIBE); echo "Should not be able to get ZMQ::SOCKOPT_UNSUBSCRIBE" . PHP_EOL; } catch (ZMQSocketException $e) {} } $removedVersion = false; /* socket option is marked mode="r" type=int php_type=int */ if (defined ("ZMQ::SOCKOPT_TYPE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-only $retval = $socket->getSockOpt(ZMQ::SOCKOPT_TYPE); if (is_int($retval) === false) { echo "Incorrect return type for ZMQ::SOCKOPT_TYPE: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL; } $tested++; try { $socket->setSockOpt(ZMQ::SOCKOPT_TYPE, 'x'); echo "Should not be able to set ZMQ::SOCKOPT_TYPE" . PHP_EOL; } catch (ZMQSocketException $e) {} } $removedVersion = false; /* socket option is marked mode="r" type=int64 php_type=int */ if (defined ("ZMQ::SOCKOPT_RCVMORE") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-only $retval = $socket->getSockOpt(ZMQ::SOCKOPT_RCVMORE); if (is_int($retval) === false) { echo "Incorrect return type for ZMQ::SOCKOPT_RCVMORE: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL; } $tested++; try { $socket->setSockOpt(ZMQ::SOCKOPT_RCVMORE, 'x'); echo "Should not be able to set ZMQ::SOCKOPT_RCVMORE" . PHP_EOL; } catch (ZMQSocketException $e) {} } $removedVersion = false; /* socket option is marked mode="r" type=socket php_type=resource */ if (defined ("ZMQ::SOCKOPT_FD") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-only $retval = $socket->getSockOpt(ZMQ::SOCKOPT_FD); if (is_resource($retval) === false) { echo "Incorrect return type for ZMQ::SOCKOPT_FD: expected=[resource] actual=[" .gettype($retval). "]" . PHP_EOL; } $tested++; try { $socket->setSockOpt(ZMQ::SOCKOPT_FD, 'x'); echo "Should not be able to set ZMQ::SOCKOPT_FD" . PHP_EOL; } catch (ZMQSocketException $e) {} } $removedVersion = false; /* socket option is marked mode="r" type=uint32 php_type=int */ if (defined ("ZMQ::SOCKOPT_EVENTS") && ($removedVersion === false || ZMQ::LIBZMQ_VERSION_MAJOR < $removedVersion)) { $test_value = 1; $socket = ZMQContext::acquire()->getSocket(ZMQ::SOCKET_SUB); // Test read-only $retval = $socket->getSockOpt(ZMQ::SOCKOPT_EVENTS); if (is_int($retval) === false) { echo "Incorrect return type for ZMQ::SOCKOPT_EVENTS: expected=[int] actual=[" .gettype($retval). "]" . PHP_EOL; } $tested++; try { $socket->setSockOpt(ZMQ::SOCKOPT_EVENTS, 'x'); echo "Should not be able to set ZMQ::SOCKOPT_EVENTS" . PHP_EOL; } catch (ZMQSocketException $e) {} } if ($tested == 0) { echo "Did not test any constants" . PHP_EOL; } echo "OK"; --EXPECT-- OK
[-] 034-unbind.phpt
[edit]
[-] 050-sharedcontext.phpt
[edit]
[-] 021-callbackwarning.phpt
[edit]
[-] 023-failedcallback.phpt
[edit]
[-] 047-auth-configure.phpt
[edit]
[-] 003-getpersistentid.phpt
[edit]
[-] 017-callbackonlyonnewsocket.phpt
[edit]
[-] bug_gh_50.phpt
[edit]
[-] 040-cert-clone.phpt
[edit]
[-] bug_gh_59_2.phpt
[edit]
[-] 027-getset.phpt
[edit]
[-] 039-cert-equals.phpt
[edit]
[-] 055-socks-proxy.phpt
[edit]
[-] 010-pollsetinvalidargs.phpt
[edit]
[-] 051-socketcount.phpt
[edit]
[-] 046-cert-apply.phpt
[edit]
[-] skipif-libzmq2.inc
[edit]
[-] bug_gh_49.phpt
[edit]
[-] libzmq2-sockopt.phpt
[edit]
[-] 028-xpub.phpt
[edit]
[-] 014-setsockoptparam.phpt
[edit]
[-] 012-pollsetremoveinvalid.phpt
[edit]
[-] bug_gh_59.phpt
[edit]
[-] 024-versionconstant.phpt
[edit]
[-] 036-device.phpt
[edit]
[-] 045-auth-allow-deny.phpt
[edit]
[-] 022-highwatermark.phpt
[edit]
[-] 043-cert-load.phpt
[edit]
[-] 020-exceptionincallback.phpt
[edit]
[-] 029-xrepxreqdevice.phpt
[edit]
[-] 052-pthreads.phpt
[edit]
[-] libzmq4-sockopt.phpt
[edit]
[-] skipif-libzmq3.inc
[edit]
[-] 026-sockettype.phpt
[edit]
[-] 018-callbackpersistent.phpt
[edit]
[-] 044-auth-construct.phpt
[edit]
[-] 009-ispersistent.phpt
[edit]
[-] bug_gh_165.phpt
[edit]
[-] 033-disconnect.phpt
[edit]
[-] 030-xrepmanualqueue.phpt
[edit]
[-] 025-sendrecvmulti.phpt
[edit]
[-] 042-cert-save.phpt
[edit]
[-] 007-addremovepoll.phpt
[edit]
[-] 038-cert-construct.phpt
[edit]
[-] 037-device-deprecated.phpt
[edit]
[-] 004-getendpoints.phpt
[edit]
[-] 001-send.phpt
[edit]
[+]
..
[-] 015-callback.phpt
[edit]
[-] 005-forceconnectarg.phpt
[edit]
[-] libzmq3-sockopt.phpt
[edit]
[-] 006-sockopt.phpt
[edit]
[-] 008-twowaystoconstruct.phpt
[edit]
[-] 035-capture.phpt
[edit]
[-] bug_gh_156.phpt
[edit]
[-] zeromq_test_helper.inc
[edit]
[-] 049-events.phpt
[edit]
[-] 016-callbackinvalidargs.phpt
[edit]
[-] 031-lastendpoint.phpt
[edit]
[-] bug_gh_43.phpt
[edit]
[-] 002-test-binary.phpt
[edit]
[-] 048-pollsetitems.phpt
[edit]
[-] 053-z85.phpt
[edit]
[-] skipif-czmq2.inc
[edit]
[-] 041-cert-meta.phpt
[edit]
[-] 013-pollclearandreuse.phpt
[edit]
[-] rose.jpg
[edit]
[-] skipif.inc
[edit]
[-] skipif-libzmq4.inc
[edit]
[-] 032-contextopt.phpt
[edit]
[-] 011-exceptions.phpt
[edit]
[-] 054-curvekeypair.phpt
[edit]