notifications
[m6w6/ext-pq] / tests / notify001.phpt
diff --git a/tests/notify001.phpt b/tests/notify001.phpt
new file mode 100644 (file)
index 0000000..edb6120
--- /dev/null
@@ -0,0 +1,38 @@
+--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;
+var_dump(stream_select($r, $w, $e, NULL));
+$consumer->poll();
+
+var_dump(stream_select($r, $w, $e, 0));
+$consumer->poll();
+?>
+DONE
+--EXPECTF--
+Test
+test(%d): this is a test
+int(1)
+test(%d): this is an async test
+int(0)
+DONE