From 5693bd4cdf2f8346d7bef96206583fa26225c1a8 Mon Sep 17 00:00:00 2001 From: Yasuo Ohgaki Date: Fri, 18 Oct 2002 07:52:09 +0000 Subject: [PATCH] Added tests for new functions --- ext/pgsql/tests/17result.phpt | 9 +++++++++ ext/pgsql/tests/18pg_escape_bytea.phpt | 10 ++++++++++ ext/pgsql/tests/19pg_ping.phpt | 10 ++++++++++ ext/pgsql/tests/20pg_get_pid.phpt | 10 ++++++++++ ext/pgsql/tests/21pg_get_notify.phpt | 10 ++++++++++ ext/pgsql/tests/README | 14 ++++++++++++++ ext/pgsql/tests/createdb.inc | 2 +- ext/pgsql/tests/large_object.inc | 18 ++++++++++++++++++ ext/pgsql/tests/pg_escape_bytea.inc | 25 +++++++++++++++++++++++++ ext/pgsql/tests/pg_get_notify.inc | 16 ++++++++++++++++ ext/pgsql/tests/pg_get_pid.inc | 13 +++++++++++++ ext/pgsql/tests/pg_ping.inc | 10 ++++++++++ ext/pgsql/tests/result.inc | 3 +++ 13 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 ext/pgsql/tests/18pg_escape_bytea.phpt create mode 100644 ext/pgsql/tests/19pg_ping.phpt create mode 100644 ext/pgsql/tests/20pg_get_pid.phpt create mode 100644 ext/pgsql/tests/21pg_get_notify.phpt create mode 100644 ext/pgsql/tests/README create mode 100644 ext/pgsql/tests/pg_escape_bytea.inc create mode 100644 ext/pgsql/tests/pg_get_notify.inc create mode 100644 ext/pgsql/tests/pg_get_pid.inc create mode 100644 ext/pgsql/tests/pg_ping.inc diff --git a/ext/pgsql/tests/17result.phpt b/ext/pgsql/tests/17result.phpt index 33acb3a682..e8c3f390de 100644 --- a/ext/pgsql/tests/17result.phpt +++ b/ext/pgsql/tests/17result.phpt @@ -37,4 +37,13 @@ array(3) { [2]=> NULL } +array(3) { + ["num"]=> + string(1) "2" + ["str"]=> + string(3) "ABC" + ["bin"]=> + NULL +} +bool(true) Ok diff --git a/ext/pgsql/tests/18pg_escape_bytea.phpt b/ext/pgsql/tests/18pg_escape_bytea.phpt new file mode 100644 index 0000000000..08832c40da --- /dev/null +++ b/ext/pgsql/tests/18pg_escape_bytea.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL pg_escape_bytea() functions +--SKIPIF-- + +--FILE-- + +--EXPECT-- +OK diff --git a/ext/pgsql/tests/19pg_ping.phpt b/ext/pgsql/tests/19pg_ping.phpt new file mode 100644 index 0000000000..eba678b55e --- /dev/null +++ b/ext/pgsql/tests/19pg_ping.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL pg_ping() functions +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) diff --git a/ext/pgsql/tests/20pg_get_pid.phpt b/ext/pgsql/tests/20pg_get_pid.phpt new file mode 100644 index 0000000000..9572751185 --- /dev/null +++ b/ext/pgsql/tests/20pg_get_pid.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL pg_get_pid() functions +--SKIPIF-- + +--FILE-- + +--EXPECT-- +OK diff --git a/ext/pgsql/tests/21pg_get_notify.phpt b/ext/pgsql/tests/21pg_get_notify.phpt new file mode 100644 index 0000000000..0ff3a74a26 --- /dev/null +++ b/ext/pgsql/tests/21pg_get_notify.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL pg_get_notify() functions +--SKIPIF-- + +--FILE-- + +--EXPECT-- +OK diff --git a/ext/pgsql/tests/README b/ext/pgsql/tests/README new file mode 100644 index 0000000000..22915127a6 --- /dev/null +++ b/ext/pgsql/tests/README @@ -0,0 +1,14 @@ +Test scripts assume: + - PostgreSQL server is installed locally + - there is a PostgreSQL account for the users running test script + - there is database named "test" + +For instance, if you login name is 'testuser', you should +have PostgreSQL user account named 'testuser' and have 'test' +database. + +If you have account and database, type "createdb test" from +command prompt to create database to execute test scripts. + +If you find problems in PostgreSQL module, please mail to +yohgaki@php.net or php-dev@lists.php.net. diff --git a/ext/pgsql/tests/createdb.inc b/ext/pgsql/tests/createdb.inc index 28a04b702d..b11883800f 100644 --- a/ext/pgsql/tests/createdb.inc +++ b/ext/pgsql/tests/createdb.inc @@ -6,7 +6,7 @@ include('config.inc'); $db = pg_connect($conn_str); if (!@pg_num_rows(@pg_query($db, "SELECT * FROM ".$table_name))) { - @pg_query($db,$table_def); + @pg_query($db,$table_def); // Create table here for ($i=0; $i < $num_test_record; $i++) { pg_query($db,"INSERT INTO ".$table_name." VALUES ($i, 'ABC');"); } diff --git a/ext/pgsql/tests/large_object.inc b/ext/pgsql/tests/large_object.inc index 5b8d1f8b72..f21912b5b6 100644 --- a/ext/pgsql/tests/large_object.inc +++ b/ext/pgsql/tests/large_object.inc @@ -3,6 +3,8 @@ include('config.inc'); $db = pg_connect($conn_str); + +// create/write/close LO pg_exec ($db, "begin"); $oid = pg_lo_create ($db); if (!$oid) echo ("pg_lo_create() error\n"); @@ -12,6 +14,7 @@ pg_lo_write ($handle, "large object data\n"); pg_lo_close ($handle); pg_exec ($db, "commit"); +// open/read/tell/seek/close LO pg_exec ($db, "begin"); $handle = pg_lo_open ($db, $oid, "w"); pg_lo_read($handle, 100); @@ -20,6 +23,7 @@ pg_lo_seek($handle, 2); pg_lo_close($handle); pg_exec ($db, "commit"); +// open/read_all/close LO pg_exec ($db, "begin"); $handle = pg_lo_open ($db, $oid, "w"); pg_lo_read_all($handle); @@ -27,6 +31,7 @@ if (pg_last_error()) echo "pg_lo_read_all() error\n".pg_last_error(); pg_lo_close($handle); pg_exec ($db, "commit"); +// unlink LO pg_exec ($db, "begin"); pg_lo_unlink($db, $oid) or print("pg_lo_unlink() error\n"); pg_exec ($db, "commit"); @@ -44,6 +49,19 @@ $oid = pg_lo_create ($db) or print("pg_lo_create() error\n"); pg_lo_unlink($db, (string)$oid) or print("pg_lo_unlink() error\n"); pg_exec ($db, "commit"); +// import/export LO +pg_query($db, 'begin'); +$oid = pg_lo_import($db, 'php.gif'); +pg_query($db, 'commit'); +pg_query($db, 'begin'); +@unlink('php.gif.exported'); +pg_lo_export($oid, 'php.gif.exported', $db); +if (!file_exists('php.gif.exported')) { + echo "Export failed\n"; +} +@unlink('php.gif.exported'); +pg_query($db, 'commit'); + echo "OK"; ?> \ No newline at end of file diff --git a/ext/pgsql/tests/pg_escape_bytea.inc b/ext/pgsql/tests/pg_escape_bytea.inc new file mode 100644 index 0000000000..249c2f158d --- /dev/null +++ b/ext/pgsql/tests/pg_escape_bytea.inc @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/ext/pgsql/tests/pg_get_notify.inc b/ext/pgsql/tests/pg_get_notify.inc new file mode 100644 index 0000000000..dfb4fe3b85 --- /dev/null +++ b/ext/pgsql/tests/pg_get_notify.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/ext/pgsql/tests/pg_get_pid.inc b/ext/pgsql/tests/pg_get_pid.inc new file mode 100644 index 0000000000..5aa8e7efa5 --- /dev/null +++ b/ext/pgsql/tests/pg_get_pid.inc @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/ext/pgsql/tests/pg_ping.inc b/ext/pgsql/tests/pg_ping.inc new file mode 100644 index 0000000000..2d9be9fadc --- /dev/null +++ b/ext/pgsql/tests/pg_ping.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/ext/pgsql/tests/result.inc b/ext/pgsql/tests/result.inc index 6982a84493..fb38938b89 100644 --- a/ext/pgsql/tests/result.inc +++ b/ext/pgsql/tests/result.inc @@ -15,6 +15,9 @@ $rec = pg_fetch_array($result, 1); var_dump($rec); $rec = pg_fetch_row($result, 1); var_dump($rec); +$rec = pg_fetch_assoc($result); +var_dump($rec); +var_dump(pg_result_seek($result, 0)); echo "Ok\n"; -- 2.50.1