Viewing File: /opt/alt/tests/alt-php83-pecl-zmq_1.1.3-1.84f0720.el8/tests/051-socketcount.phpt

--TEST--
Test socket count variations
--SKIPIF--
<?php
	require_once(dirname(__FILE__) . '/skipif.inc'); 
	if (!in_array ('acquire', get_class_methods ('ZMQContext')))
		die ('skip');
	if (!in_array ('getsocketcount', get_class_methods ('ZMQContext')))
		die ('skip');
?>
--FILE--
<?php

include dirname(__FILE__) . '/zeromq_test_helper.inc';

$context = new ZMQContext(1, false);

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

var_dump ($context->getSocketCount());

unset($socket1);
var_dump ($context->getSocketCount());

unset($socket2);
var_dump ($context->getSocketCount());


$context = new ZMQContext(7, true);

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

var_dump ($context->getSocketCount());

unset($socket1);
var_dump ($context->getSocketCount());

// Persistent socket should stay in count
unset($socket2);
var_dump ($context->getSocketCount());

$context = ZMQContext::acquire();

$socket1 = new ZMQSocket($context, ZMQ::SOCKET_REP);
$socket2 = $context->getSocket(ZMQ::SOCKET_REQ, 'persistent id');

var_dump ($context->getSocketCount());

unset($socket1);
var_dump ($context->getSocketCount());

// Persistent socket should stay in count
unset($socket2);
var_dump ($context->getSocketCount());

echo "OK";

--EXPECT--
int(2)
int(1)
int(0)
int(2)
int(1)
int(1)
int(2)
int(1)
int(1)
OK
Back to Directory File Manager
<