1
0
mirror of https://github.com/danog/ext-pq.git synced 2024-11-27 04:14:51 +01:00
ext-pq/tests/async002.phpt
Michael Wallner cb69b6218d finish port
2015-08-19 18:40:34 +02:00

62 lines
1.0 KiB
PHP

--TEST--
async reset
--SKIPIF--
<?php include "_skipif.inc"; ?>
--FILE--
<?php
echo "Test\n";
include "_setup.inc";
$c = new pq\Connection(PQ_DSN, true);
function complete($c) {
$s = array($c->status);
echo "W";
$w = array($c->socket);
$r = $e = null;
stream_select($r, $w, $e, null);
while (true) {
$s[] = $c->status;
echo "P";
switch ($c->poll()) {
case pq\Connection::POLLING_READING:
echo "R";
$w = $e = null;
$r = array($c->socket);
stream_select($r, $w, $e, NULL);
break;
case pq\Connection::POLLING_WRITING:
echo "W";
$w = array($c->socket);
$r = $e = null;
stream_select($r, $w, $e, null);
break;
case pq\Connection::POLLING_FAILED:
echo "F";
break 2;
case pq\Connection::POLLING_OK:
echo "S";
break 2;
}
}
$s[] = $c->status;
printf("\n%s\n", implode(",", $s));
}
complete($c);
if ($c->status == pq\Connection::OK) {
$c->resetAsync();
complete($c);
}
?>
DONE
--EXPECTREGEX--
Test
(WP(RP)*)+S
2(,\d)*,0
(WP(RP)*)+S
2(,\d)*,0
DONE