release 2.1.6
[m6w6/ext-pq] / tests / async001.phpt
1 --TEST--
2 async connect
3 --SKIPIF--
4 <?php include "_skipif.inc"; ?>
5 --FILE--
6 <?php
7 echo "Test\n";
8
9 include "_setup.inc";
10
11 $c = new pq\Connection(PQ_DSN, true);
12 $s = array($c->status);
13 echo "W";
14 $w = array($c->socket);
15 $r = $e = null;
16 stream_select($r, $w, $e, null);
17 while (true) {
18 $s[] = $c->status;
19 echo "P";
20 switch ($c->poll()) {
21 case pq\Connection::POLLING_READING:
22 echo "R";
23 $w = $e = null;
24 $r = array($c->socket);
25 stream_select($r, $w, $e, NULL);
26 break;
27 case pq\Connection::POLLING_WRITING:
28 echo "W";
29 $w = array($c->socket);
30 $r = $e = null;
31 stream_select($r, $w, $e, null);
32 break;
33 case pq\Connection::POLLING_FAILED:
34 echo "F";
35 break 2;
36 case pq\Connection::POLLING_OK:
37 echo "S";
38 break 2;
39 }
40 }
41 $s[] = $c->status;
42 printf("\n%s\n", implode(",", $s));
43 ?>
44 DONE
45 --EXPECTREGEX--
46 Test
47 (WP(RP)*)+S
48 2(,\d)*,0
49 DONE