From f7aeb22e11b82a9e91b6be69e373f11d88216c8a Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 21 Jan 2013 12:13:04 +0100 Subject: [PATCH] tests --- tests/_setup.inc | 2 ++ tests/_skipif.inc | 5 +++++ tests/basic001.phpt | 51 ++++++++++++++++++++++++++++++++++++++++++ tests/basic002.phpt | 22 ++++++++++++++++++ tests/stm_desc001.phpt | 22 ++++++++++++++++++ 5 files changed, 102 insertions(+) create mode 100644 tests/_setup.inc create mode 100644 tests/_skipif.inc create mode 100644 tests/basic001.phpt create mode 100644 tests/basic002.phpt create mode 100644 tests/stm_desc001.phpt 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 -- 2.30.2