-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikko Koppanen
committed
Sep 19, 2010
1 parent
f7ab1d4
commit 9586232
Showing
8 changed files
with
259 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--TEST-- | ||
Test basic callback usage | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
include dirname(__FILE__) . '/zeromq_test_helper.inc'; | ||
|
||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'my persistent 1', 'bind_callback'); | ||
var_dump($socket->getEndpoints()); | ||
|
||
$ctx = new ZMQContext(); | ||
$socket = $ctx->getSocket(ZMQ::SOCKET_REQ, 'my persistent 2', 'bind_callback'); | ||
var_dump($socket->getEndpoints()); | ||
|
||
|
||
--EXPECT-- | ||
array(2) { | ||
["connect"]=> | ||
array(0) { | ||
} | ||
["bind"]=> | ||
array(1) { | ||
[0]=> | ||
string(20) "tcp://127.0.0.1:5566" | ||
} | ||
} | ||
array(2) { | ||
["connect"]=> | ||
array(0) { | ||
} | ||
["bind"]=> | ||
array(1) { | ||
[0]=> | ||
string(20) "tcp://127.0.0.1:5567" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Test invalid args for callback | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
try { | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'my persistent 1', 'this_function_does_not_exist'); | ||
echo "Fail\n"; | ||
} catch (ZMQSocketException $e) { | ||
echo "OK\n"; | ||
} | ||
|
||
try { | ||
$ctx = new ZMQContext(); | ||
$socket = $ctx->getSocket(ZMQ::SOCKET_REQ, 'my persistent 2', 'this_function_does_not_exist'); | ||
echo "Fail\n"; | ||
} catch (ZMQSocketException $e) { | ||
echo "OK\n"; | ||
} | ||
|
||
--EXPECT-- | ||
OK | ||
OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--TEST-- | ||
Test that callback is only called on new socket | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
include dirname(__FILE__) . '/zeromq_test_helper.inc'; | ||
|
||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback'); | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback'); | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback'); | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback'); | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'bind_callback'); | ||
|
||
$array = $socket->getEndpoints(); | ||
|
||
echo count($array['bind']) . "\n"; | ||
echo "OK"; | ||
|
||
--EXPECT-- | ||
1 | ||
OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--TEST-- | ||
Test callback arguments on persistent and non-persistent socket | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
function dump_args(ZMQSocket $s, $p = null) | ||
{ | ||
var_dump($s, $p); | ||
} | ||
|
||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'dump_args'); | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, null, 'dump_args'); | ||
|
||
echo "OK"; | ||
|
||
--EXPECTF-- | ||
object(ZMQSocket)#%d (0) { | ||
} | ||
string(17) "persistent_socket" | ||
object(ZMQSocket)#%d (0) { | ||
} | ||
NULL | ||
OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--TEST-- | ||
Test callback edge-cases | ||
--SKIPIF-- | ||
--XFAIL-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
function try_to_force_ref(&$a, $b) | ||
{ | ||
echo "CALLED\n"; | ||
} | ||
|
||
function throw_exception($socket, $pid = null) | ||
{ | ||
/* This exception should bubble up */ | ||
throw new Exception("hello world"); | ||
} | ||
|
||
try { | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'try_to_force_ref'); | ||
echo "Fail\n"; | ||
} catch (ZMQSocketException $e) { | ||
echo $e->getMessage() . "\n"; | ||
} | ||
|
||
try { | ||
$socket = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, 'persistent_socket', 'throw_exception'); | ||
echo "Fail\n"; | ||
} catch (ZMQSocketException $e) { | ||
echo $e->getMessage() . "\n"; | ||
} | ||
|
||
--EXPECTF-- | ||
Parameter 1 to try_to_force_ref() expected to be a reference, value given | ||
hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters