diff options
-rw-r--r-- | ext/pgsql/tests/01createdb.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/02connection.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/03sync_query.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/04async_query.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/05large_object.phpt | 11 | ||||
-rw-r--r-- | ext/pgsql/tests/06copy.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/07optional.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/98old_api.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/9999dropdb.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/async_query.inc | 59 | ||||
-rw-r--r-- | ext/pgsql/tests/config.inc | 12 | ||||
-rw-r--r-- | ext/pgsql/tests/connection.inc | 44 | ||||
-rw-r--r-- | ext/pgsql/tests/copy.inc | 8 | ||||
-rw-r--r-- | ext/pgsql/tests/createdb.inc | 22 | ||||
-rw-r--r-- | ext/pgsql/tests/dropdb.inc | 15 | ||||
-rw-r--r-- | ext/pgsql/tests/large_object.inc | 36 | ||||
-rw-r--r-- | ext/pgsql/tests/old_api.inc | 26 | ||||
-rw-r--r-- | ext/pgsql/tests/optional.inc | 13 | ||||
-rw-r--r-- | ext/pgsql/tests/skipif.inc | 19 | ||||
-rw-r--r-- | ext/pgsql/tests/sync_query.inc | 47 |
20 files changed, 392 insertions, 0 deletions
diff --git a/ext/pgsql/tests/01createdb.phpt b/ext/pgsql/tests/01createdb.phpt new file mode 100644 index 0000000000..3b34ed537e --- /dev/null +++ b/ext/pgsql/tests/01createdb.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL create db +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("createdb.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/02connection.phpt b/ext/pgsql/tests/02connection.phpt new file mode 100644 index 0000000000..fd1333dfe6 --- /dev/null +++ b/ext/pgsql/tests/02connection.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL connection +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("connection.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/03sync_query.phpt b/ext/pgsql/tests/03sync_query.phpt new file mode 100644 index 0000000000..0f2e048959 --- /dev/null +++ b/ext/pgsql/tests/03sync_query.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL sync query +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("sync_query.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/04async_query.phpt b/ext/pgsql/tests/04async_query.phpt new file mode 100644 index 0000000000..a3d17699b9 --- /dev/null +++ b/ext/pgsql/tests/04async_query.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL async query +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("async_query.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/05large_object.phpt b/ext/pgsql/tests/05large_object.phpt new file mode 100644 index 0000000000..ef0bc15db9 --- /dev/null +++ b/ext/pgsql/tests/05large_object.phpt @@ -0,0 +1,11 @@ +--TEST-- +PostgreSQL large object +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("large_object.inc"); +?> +--EXPECT-- +large object data +OK diff --git a/ext/pgsql/tests/06copy.phpt b/ext/pgsql/tests/06copy.phpt new file mode 100644 index 0000000000..dbbe1ff4d6 --- /dev/null +++ b/ext/pgsql/tests/06copy.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL copy functions +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("copy.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/07optional.phpt b/ext/pgsql/tests/07optional.phpt new file mode 100644 index 0000000000..f8b8cbeec7 --- /dev/null +++ b/ext/pgsql/tests/07optional.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL optional functions +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("optional.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/98old_api.phpt b/ext/pgsql/tests/98old_api.phpt new file mode 100644 index 0000000000..c6f8070c23 --- /dev/null +++ b/ext/pgsql/tests/98old_api.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL old api +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("old_api.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/9999dropdb.phpt b/ext/pgsql/tests/9999dropdb.phpt new file mode 100644 index 0000000000..d60e2dce99 --- /dev/null +++ b/ext/pgsql/tests/9999dropdb.phpt @@ -0,0 +1,10 @@ +--TEST-- +PostgreSQL drop db +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("dropdb.inc"); +?> +--EXPECT-- +OK diff --git a/ext/pgsql/tests/async_query.inc b/ext/pgsql/tests/async_query.inc new file mode 100644 index 0000000000..ac70809095 --- /dev/null +++ b/ext/pgsql/tests/async_query.inc @@ -0,0 +1,59 @@ +<?php + +include('config.inc'); + +$db = pg_connect($conn_str); + +if (!pg_send_query($db, "SELECT * FROM ".$table_name.";")) { + echo "pg_send_query() error\n"; +} +while(pg_connection_busy($db)); // busy wait: intended +if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) { + echo "pg_connection_status() error\n"; +} +if (!($result = pg_get_result($db))) +{ + echo "pg_get_result() error\n"; +} + +if (!($rows = pg_num_rows($result))) { + echo "pg_num_rows() error\n"; +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_array($result, $i, PGSQL_NUM); +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_object($result, $i, PGSQL_ASSOC); +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_row($result, $i); +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_result($result, $i, 0); +} + +pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); +pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";")); +pg_field_name($result, 0); +pg_field_num($result, $field_name); +pg_field_size($result, 0); +pg_field_type($result, 0); +pg_field_prtlen($result, 0); +pg_field_is_null($result, 0); + +if (!pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');")) +{ + echo "pg_send_query() error\n"; +} + +pg_last_oid($result); +pg_free_result($result); + + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/config.inc b/ext/pgsql/tests/config.inc new file mode 100644 index 0000000000..c31c1cadc4 --- /dev/null +++ b/ext/pgsql/tests/config.inc @@ -0,0 +1,12 @@ +<?php +// These vars are used to connect db and create test table. +// values can be set to meet your environment + +$conn_str = "host=localhost"; // connection string +$table_name = "php_pgsql_test"; // test table that should be exist +$num_test_record = 1000; // Number of records to create + +$table_def = "CREATE TABLE php_pgsql_test (num int, str text);"; // Test table +$field_name = "num"; // For pg_field_num() + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/connection.inc b/ext/pgsql/tests/connection.inc new file mode 100644 index 0000000000..e6e9c143af --- /dev/null +++ b/ext/pgsql/tests/connection.inc @@ -0,0 +1,44 @@ +<?php +// connection function tests + +include('config.inc'); + +$db = pg_pconnect($conn_str); +if (pg_connection_status($db) != PGSQL_CONNECTION_OK) +{ + echo "pg_connection_status() error\n"; +} +if (!pg_connection_reset($db)) +{ + echo "pg_connection_reset() error\n"; +} +if (pg_connection_busy($db)) +{ + echo "pg_connection_busy() error\n"; +} +if (!pg_host($db)) +{ + echo "pg_host() error\n"; +} +if (!pg_dbname($db)) +{ + echo "pg_dbname() error\n"; +} +if (!pg_port($db)) +{ + echo "pg_port() error\n"; +} +if (pg_tty($db)) +{ + echo "pg_tty() error\n"; +} +if (pg_options($db)) +{ + echo "pg_options() error\n"; +} + +pg_close($db); + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/copy.inc b/ext/pgsql/tests/copy.inc new file mode 100644 index 0000000000..52b6e1d748 --- /dev/null +++ b/ext/pgsql/tests/copy.inc @@ -0,0 +1,8 @@ +<?php + +include('config.inc'); + + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/createdb.inc b/ext/pgsql/tests/createdb.inc new file mode 100644 index 0000000000..ed425387fa --- /dev/null +++ b/ext/pgsql/tests/createdb.inc @@ -0,0 +1,22 @@ +<?php +// create test table + +include('config.inc'); + +$db = pg_connect($conn_str); +if (!@pg_num_rows(@pg_query($db, "SELECT * FROM ".$table_name))) +{ + @pg_query($db,$table_def); + for ($i=0; $i < $num_test_record; $i++) { + pg_query($db,"INSERT INTO php_pgsql_test VALUES ($i, 'ABC');"); + } +} +else { + echo pg_last_error()."\n"; +} + +pg_close($db); + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/dropdb.inc b/ext/pgsql/tests/dropdb.inc new file mode 100644 index 0000000000..93f4d70789 --- /dev/null +++ b/ext/pgsql/tests/dropdb.inc @@ -0,0 +1,15 @@ +<?php +// drop test table + +include('config.inc'); + +// $db = pg_connect($conn_str); +// if (pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name))) +// { +// pg_query($db, "DROP TABLE ".$table_name); +// } +// pg_close($db); + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/large_object.inc b/ext/pgsql/tests/large_object.inc new file mode 100644 index 0000000000..2a1159c8c4 --- /dev/null +++ b/ext/pgsql/tests/large_object.inc @@ -0,0 +1,36 @@ +<?php + +include('config.inc'); + +$db = pg_connect("host=localhost"); +pg_exec ($db, "begin"); +$oid = pg_lo_create ($db); +if (!$oid) echo ("pg_lo_create() error\n"); +$handle = pg_lo_open ($db, $oid, "w"); +if (!$handle) echo ("pg_lo_open() error\n"); +pg_lo_write ($handle, "large object data\n"); +pg_lo_close ($handle); +pg_exec ($db, "commit"); + +pg_exec ($db, "begin"); +$handle = pg_lo_open ($db, $oid, "w"); +pg_lo_read($handle, 100); +pg_lo_tell($handle); +pg_lo_seek($handle, 2); +pg_lo_close($handle); +pg_exec ($db, "commit"); + +pg_exec ($db, "begin"); +$handle = pg_lo_open ($db, $oid, "w"); +pg_lo_read_all($handle); +if (pg_last_error()) echo "pg_lo_read_all() error\n".pg_last_error(); +pg_lo_close($handle); +pg_exec ($db, "commit"); + +pg_exec ($db, "begin"); +pg_lo_unlink($oid); +pg_exec ($db, "commit"); + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/old_api.inc b/ext/pgsql/tests/old_api.inc new file mode 100644 index 0000000000..4995961831 --- /dev/null +++ b/ext/pgsql/tests/old_api.inc @@ -0,0 +1,26 @@ +<?php + +include('config.inc'); + +$db = pg_connect($conn_str); +$result = pg_exec("SELECT * FROM ".$table_name); +pg_numrows($result); +pg_numfields($result); +pg_fieldname($result, 0); +pg_fieldsize($result, $field_name); +pg_fieldtype($result, 0); +pg_fieldprtlen($result, 0); +pg_fieldisnull($result, 0); + +pg_result($result,0,0); +$result = pg_exec("INSERT INTO ".$table_name." VALUES (7777, 'KKK')"); +$oid = pg_getlastoid($result); +pg_freeresult($result); +pg_errormessage(); +$result = pg_exec("UPDATE ".$table_name." SET str = 'QQQ' WHERE str like 'RGD';"); +pg_cmdtuples($result); + + + +echo "OK"; +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/optional.inc b/ext/pgsql/tests/optional.inc new file mode 100644 index 0000000000..87dbfd39d3 --- /dev/null +++ b/ext/pgsql/tests/optional.inc @@ -0,0 +1,13 @@ +<?php +// optional functions + +include('config.inc'); + +$db = pg_connect($conn_str); +$enc = pg_client_encoding($db); + +pg_set_client_encoding($db, $enc); + +echo "OK"; + +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc new file mode 100644 index 0000000000..d1b075e3ed --- /dev/null +++ b/ext/pgsql/tests/skipif.inc @@ -0,0 +1,19 @@ +<?php +// This script prints "skip" unless: +// * the pgsql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("pgsql") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("pgsql$dlext"); +} +if (!extension_loaded("pgsql")) { + die("skip\n"); +} +$conn = @pg_connect("host=localhost dbname=test"); +if (!is_resource($conn)) { + die("skip\n"); +} +?>
\ No newline at end of file diff --git a/ext/pgsql/tests/sync_query.inc b/ext/pgsql/tests/sync_query.inc new file mode 100644 index 0000000000..5a75b2c88c --- /dev/null +++ b/ext/pgsql/tests/sync_query.inc @@ -0,0 +1,47 @@ +<?php + +include('config.inc'); + +$db = pg_connect($conn_str); + +$result = pg_query($db, "SELECT * FROM ".$table_name.";"); +if (!($rows = pg_num_rows($result))) +{ + echo "pg_num_row() error\n"; +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_array($result, $i, PGSQL_NUM); +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_object($result, $i, PGSQL_ASSOC); +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_row($result, $i); +} +for ($i=0; $i < $rows; $i++) +{ + pg_fetch_result($result, $i, 0); +} + +pg_result_error($result); +pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); +pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";")); +pg_field_name($result, 0); +pg_field_num($result, $field_name); +pg_field_size($result, 0); +pg_field_type($result, 0); +pg_field_prtlen($result, 0); +pg_field_is_null($result, 0); + +$result = pg_query($db, "INSERT INTO ".$table_name." VALUES (9999, 'ABC');"); +pg_last_oid($result); + +pg_free_result($result); +pg_close($db); + +echo "OK"; + +?>
\ No newline at end of file |