pq\Types, pq\LOB
[m6w6/ext-pq] / tests / notify001.phpt
1 --TEST--
2 notify
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $consumer = new pq\Connection(PQ_DSN);
12 $consumer->listen("test", function($channel, $message, $pid) {
13 printf("%s(%d): %s\n", $channel, $pid, $message);
14 });
15
16 $producer = new pq\Connection(PQ_DSN);
17 $producer->notify("test", "this is a test");
18
19 $consumer->exec("select 1");
20
21 $producer->notify("test", "this is an async test");
22
23 $r = array($consumer->socket);
24 $w = null; $e = null;
25 var_dump(stream_select($r, $w, $e, NULL));
26 $consumer->poll();
27
28 $producer->notify("other", "this should not show up");
29
30 var_dump(stream_select($r, $w, $e, 0));
31 $consumer->poll();
32
33 $producer->notify("test", "just to be sure");
34
35 $r = array($consumer->socket);
36 $w = null; $e = null;
37 var_dump(stream_select($r, $w, $e, NULL));
38 $consumer->poll();
39
40 ?>
41 DONE
42 --EXPECTF--
43 Test
44 test(%d): this is a test
45 int(1)
46 test(%d): this is an async test
47 int(0)
48 int(1)
49 test(%d): just to be sure
50 DONE