1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-12-11 08:59:45 +01:00
ext-pq/tests/notify001.phpt

57 lines
1.1 KiB
Plaintext
Raw Normal View History

2013-01-21 23:31:42 +01:00
--TEST--
notify
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";
$consumer = new pq\Connection(PQ_DSN);
$consumer->listen("test", function($channel, $message, $pid) {
printf("%s(%d): %s\n", $channel, $pid, $message);
});
$producer = new pq\Connection(PQ_DSN);
$producer->notify("test", "this is a test");
$consumer->exec("select 1");
$producer->notify("test", "this is an async test");
$r = array($consumer->socket);
$w = null; $e = null;
stream_select($r, $w, $e, NULL);
2013-01-21 23:31:42 +01:00
$consumer->poll();
2013-01-23 00:02:55 +01:00
$producer->notify("other", "this should not show up");
stream_select($r, $w, $e, 0,1000);
2013-01-21 23:31:42 +01:00
$consumer->poll();
2013-01-23 00:02:55 +01:00
$producer->notify("test", "just to be sure");
$r = array($consumer->socket);
$w = null; $e = null;
stream_select($r, $w, $e, 0,1000);
2014-07-14 18:02:57 +02:00
$consumer->poll();
$consumer->unlisten("test");
$producer->notify("test", "this shouldn't show up either");
$r = array($consumer->socket);
$w = null; $e = null;
stream_select($r, $w, $e, 0,1000);
2013-01-23 00:02:55 +01:00
$consumer->poll();
2013-01-21 23:31:42 +01:00
?>
DONE
--EXPECTF--
Test
test(%d): this is a test
test(%d): this is an async test
2013-01-23 00:02:55 +01:00
test(%d): just to be sure
2013-01-21 23:31:42 +01:00
DONE