mirror of
https://github.com/danog/ext-pq.git
synced 2024-11-26 11:54:50 +01:00
add tests
This commit is contained in:
parent
b73911f65d
commit
c223e1c70b
41
tests/crash_result_iterator.phpt
Normal file
41
tests/crash_result_iterator.phpt
Normal file
@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
crash result iterator
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "_skipif.inc";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test\n";
|
||||
|
||||
include "_setup.inc";
|
||||
|
||||
$conn = new pq\Connection(PQ_DSN);
|
||||
|
||||
$sql = "
|
||||
SELECT id
|
||||
FROM generate_series(1,3) id
|
||||
ORDER BY id ASC
|
||||
LIMIT 5
|
||||
";
|
||||
|
||||
foreach ($conn->exec($sql) as $row) {
|
||||
var_dump($row);
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
Test
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(1)
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(2)
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
int(3)
|
||||
}
|
||||
===DONE===
|
20
tests/crash_stm_reverse_dep.phpt
Normal file
20
tests/crash_stm_reverse_dep.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
crash stm reverse dependency from connection
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "_skipif.inc";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test\n";
|
||||
|
||||
include "_setup.inc";
|
||||
|
||||
$c = new pq\Connection(PQ_DSN);
|
||||
$c->s = $c->prepare("test", "SELECT 1");
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
Test
|
||||
===DONE===
|
43
tests/crash_unbuffered_async_prepare.phpt
Normal file
43
tests/crash_unbuffered_async_prepare.phpt
Normal file
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
crash unbuffered async prepare
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "_skipif.inc";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
echo "Test\n";
|
||||
|
||||
include "_setup.inc";
|
||||
|
||||
function complete($c) {
|
||||
do {
|
||||
while ($c->busy) {
|
||||
$r = array($c->socket);
|
||||
$w = $e = null;
|
||||
if (stream_select($r, $w, $e, null)) {
|
||||
$c->poll();
|
||||
}
|
||||
}
|
||||
} while ($c->getResult());
|
||||
}
|
||||
|
||||
try {
|
||||
$c = new pq\Connection(PQ_DSN);
|
||||
$c->unbuffered = true;
|
||||
|
||||
$s = $c->prepareAsync("test", "SELECT * from generate_series(1,2)");
|
||||
complete($c);
|
||||
|
||||
$r = $s->execAsync();
|
||||
complete($c);
|
||||
} catch (Exception $e) {
|
||||
echo $e;
|
||||
}
|
||||
unset($c);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
Test
|
||||
===DONE===
|
Loading…
Reference in New Issue
Block a user