From: Michael Wallner Date: Mon, 21 Jan 2013 11:13:04 +0000 (+0100) Subject: tests X-Git-Tag: v0.1.0~54 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=f7aeb22e11b82a9e91b6be69e373f11d88216c8a;p=m6w6%2Fext-pq tests --- diff --git a/tests/_setup.inc b/tests/_setup.inc new file mode 100644 index 0000000..0af687a --- /dev/null +++ b/tests/_setup.inc @@ -0,0 +1,2 @@ + +--FILE-- +exec("SELECT 1 as one, 2 as two from generate_series(1,2)"); + +var_dump($res->status == pq\Result::TUPLES_OK); +var_dump($res->numRows); +var_dump($res->numCols); + +foreach ($res as $rowNum => $rowData) { + printf("%d.0 => %d\n", $rowNum, $rowData[0]); + printf("%d.1 => %d\n", $rowNum, $rowData[1]); +} +$res->fetchType = pq\Result::FETCH_ASSOC; +foreach ($res as $rowNum => $rowData) { + printf("%d.0 => %d\n", $rowNum, $rowData["one"]); + printf("%d.1 => %d\n", $rowNum, $rowData["two"]); +} +$res->fetchType = pq\Result::FETCH_OBJECT; +foreach ($res as $rowNum => $rowData) { + printf("%d.0 => %d\n", $rowNum, $rowData->one); + printf("%d.1 => %d\n", $rowNum, $rowData->two); +} +?> +DONE +--EXPECT-- +Test +bool(true) +int(2) +int(2) +0.0 => 1 +0.1 => 2 +1.0 => 1 +1.1 => 2 +0.0 => 1 +0.1 => 2 +1.0 => 1 +1.1 => 2 +0.0 => 1 +0.1 => 2 +1.0 => 1 +1.1 => 2 +DONE diff --git a/tests/basic002.phpt b/tests/basic002.phpt new file mode 100644 index 0000000..ce3b6c9 --- /dev/null +++ b/tests/basic002.phpt @@ -0,0 +1,22 @@ +--TEST-- +basic functionality +--SKIPIF-- + +--FILE-- +prepare("test1", "SELECT \$1",array($c->types->byName->text->oid)); +$r = $s->exec(array("fooo")); + +printf("%s\n", $r->errorMessage); +printf("%s\n", $r->fetchCol()); +?> +DONE +--EXPECT-- +Test + +fooo +DONE diff --git a/tests/stm_desc001.phpt b/tests/stm_desc001.phpt new file mode 100644 index 0000000..ae3e51a --- /dev/null +++ b/tests/stm_desc001.phpt @@ -0,0 +1,22 @@ +--TEST-- +pq\Statment::desc() +--SKIPIF-- + +--FILE-- +prepare("test1", "SELECT NOW() - \$1"); +$r = $s->exec(array("2012-12-12 12:12:12")); +$d = $s->desc(); + +printf("%s\n", $c->types->byOid->{$d[0]}->typname); + +?> +DONE +--EXPECT-- +Test +timestamptz +DONE