PATH:
opt
/
alt
/
tests
/
alt-php85-pecl-zmq_1.1.3-2.84f0720.el8
/
tests
--TEST-- Test device callbacks --SKIPIF-- <?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> --FILE-- <?php function proper_microtime () { return round ((microtime (true) * 1000)); } class CbStateData { protected $_counter = 0; protected $_name; public function __construct ($name) { $this->_name = $name; } public function getName () { return $this->_name; } public function increment () { return ++$this->_counter; } public function getCount () { return $this->_counter; } public function reset () { $this->_counter = 0; } } class test { function foo ($user_data) { return false; } } $test = new test (); $ctx = new ZMQContext (); $device = new ZMQDevice($ctx->getSocket(ZMQ::SOCKET_SUB), $ctx->getSocket(ZMQ::SOCKET_PUB)); $last_called = proper_microtime (); $user_data = new CbStateData ('timer'); $orig_cb = function ($user_data) use (&$last_called, $device) { echo "Triggered for {$device->getTimerTimeout ()}ms timeout" . PHP_EOL; $time_elapsed = (proper_microtime () - $last_called) + 1; if ($time_elapsed < $device->getTimerTimeout ()) { echo "Called too early, only {$time_elapsed}ms elapsed, expected {$device->getTimerTimeout ()}" . PHP_EOL; } $device->setTimerTimeout ($device->getTimerTimeout () + 50); $last_called = proper_microtime (); echo "{$user_data->getName ()} function called {$user_data->increment ()} times\n"; return $user_data->getCount() < 3 ? true : false; }; // Setup callback and user data for callback $device->setTimerCallback ($orig_cb, 100, $user_data); // Run first time $device->run (); $device->setTimerCallback (array ($test, 'foo'), 100, $user_data); $device->setTimerCallback (array ($test, 'foo'), 100, $user_data); $device->setTimerCallback ($orig_cb, 100, $user_data); sleep (1); // Run second time $user_data->reset (); $device->setTimerTimeout (110); $device->run (); echo "OK"; ?> --EXPECT-- Triggered for 100ms timeout timer function called 1 times Triggered for 150ms timeout timer function called 2 times Triggered for 200ms timeout timer function called 3 times Triggered for 110ms timeout timer function called 1 times Triggered for 160ms timeout timer function called 2 times Triggered for 210ms timeout timer function called 3 times 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]