cvs: php4 /ext/pgsql/tests 01createdb.phpt 02connection.phpt 03sync_query.phpt 04async_query.phpt 05large_object.phpt 06copy.phpt 07optional.phpt
98old_api.phpt 9999dropdb.phpt async_query.inc config.inc connection.inc copy.inc createdb.inc dropdb.inc large_object.inc old_api.inc optional.inc
skipif.inc sync_query.inc
| From: | Yasuo Ohgaki | Date: | Mon, 17 Dec 2001 00:16:48 +0000 |
| Subject: | cvs: php4 /ext/pgsql/tests 01createdb.phpt 02connection.phpt 03sync_query.phpt 04async_query.phpt 05large_object.phpt 06copy.phpt 07optional.phpt 98old_api.phpt 9999dropdb.phpt async_query.inc config.inc connection.inc copy.inc createdb.inc dropdb.inc large_object.inc old_api.inc optional.inc skipif.inc sync_query.inc |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8688@lists.php.net to get a copy of this message | ||
yohgaki Sun Dec 16 19:16:48 2001 EDT
Added files:
/php4/ext/pgsql/tests 01createdb.phpt 02connection.phpt
03sync_query.phpt 04async_query.phpt
05large_object.phpt 06copy.phpt
07optional.phpt 98old_api.phpt
9999dropdb.phpt async_query.inc config.inc
connection.inc copy.inc createdb.inc
dropdb.inc large_object.inc old_api.inc
optional.inc skipif.inc sync_query.inc
Log:
Added test files
Index: php4/ext/pgsql/tests/01createdb.phpt +++ php4/ext/pgsql/tests/01createdb.phpt --TEST-- PostgreSQL create db --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("createdb.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/02connection.phpt +++ php4/ext/pgsql/tests/02connection.phpt --TEST-- PostgreSQL connection --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("connection.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/03sync_query.phpt +++ php4/ext/pgsql/tests/03sync_query.phpt --TEST-- PostgreSQL sync query --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("sync_query.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/04async_query.phpt +++ php4/ext/pgsql/tests/04async_query.phpt --TEST-- PostgreSQL async query --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("async_query.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/05large_object.phpt +++ php4/ext/pgsql/tests/05large_object.phpt --TEST-- PostgreSQL large object --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("large_object.inc"); ?> --EXPECT-- large object data OK Index: php4/ext/pgsql/tests/06copy.phpt +++ php4/ext/pgsql/tests/06copy.phpt --TEST-- PostgreSQL copy functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("copy.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/07optional.phpt +++ php4/ext/pgsql/tests/07optional.phpt --TEST-- PostgreSQL optional functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("optional.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/98old_api.phpt +++ php4/ext/pgsql/tests/98old_api.phpt --TEST-- PostgreSQL old api --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("old_api.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/9999dropdb.phpt +++ php4/ext/pgsql/tests/9999dropdb.phpt --TEST-- PostgreSQL drop db --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("dropdb.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/async_query.inc +++ php4/ext/pgsql/tests/async_query.inc <?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"; ?> Index: php4/ext/pgsql/tests/config.inc +++ php4/ext/pgsql/tests/config.inc <?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() ?> Index: php4/ext/pgsql/tests/connection.inc +++ php4/ext/pgsql/tests/connection.inc <?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"; ?> Index: php4/ext/pgsql/tests/copy.inc +++ php4/ext/pgsql/tests/copy.inc <?php include('config.inc'); echo "OK"; ?> Index: php4/ext/pgsql/tests/createdb.inc +++ php4/ext/pgsql/tests/createdb.inc <?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"; ?> Index: php4/ext/pgsql/tests/dropdb.inc +++ php4/ext/pgsql/tests/dropdb.inc <?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"; ?> Index: php4/ext/pgsql/tests/large_object.inc +++ php4/ext/pgsql/tests/large_object.inc <?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"; ?> Index: php4/ext/pgsql/tests/old_api.inc +++ php4/ext/pgsql/tests/old_api.inc <?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"; ?> Index: php4/ext/pgsql/tests/optional.inc +++ php4/ext/pgsql/tests/optional.inc <?php // optional functions include('config.inc'); $db = pg_connect($conn_str); $enc = pg_client_encoding($db); pg_set_client_encoding($db, $enc); echo "OK"; ?> Index: php4/ext/pgsql/tests/skipif.inc +++ php4/ext/pgsql/tests/skipif.inc <?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"); } ?> Index: php4/ext/pgsql/tests/sync_query.inc +++ php4/ext/pgsql/tests/sync_query.inc <?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"; ?>
Index: php4/ext/pgsql/tests/01createdb.phpt +++ php4/ext/pgsql/tests/01createdb.phpt --TEST-- PostgreSQL create db --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("createdb.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/02connection.phpt +++ php4/ext/pgsql/tests/02connection.phpt --TEST-- PostgreSQL connection --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("connection.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/03sync_query.phpt +++ php4/ext/pgsql/tests/03sync_query.phpt --TEST-- PostgreSQL sync query --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("sync_query.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/04async_query.phpt +++ php4/ext/pgsql/tests/04async_query.phpt --TEST-- PostgreSQL async query --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("async_query.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/05large_object.phpt +++ php4/ext/pgsql/tests/05large_object.phpt --TEST-- PostgreSQL large object --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("large_object.inc"); ?> --EXPECT-- large object data OK Index: php4/ext/pgsql/tests/06copy.phpt +++ php4/ext/pgsql/tests/06copy.phpt --TEST-- PostgreSQL copy functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("copy.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/07optional.phpt +++ php4/ext/pgsql/tests/07optional.phpt --TEST-- PostgreSQL optional functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("optional.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/98old_api.phpt +++ php4/ext/pgsql/tests/98old_api.phpt --TEST-- PostgreSQL old api --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("old_api.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/9999dropdb.phpt +++ php4/ext/pgsql/tests/9999dropdb.phpt --TEST-- PostgreSQL drop db --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("dropdb.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/async_query.inc +++ php4/ext/pgsql/tests/async_query.inc <?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"; ?> Index: php4/ext/pgsql/tests/config.inc +++ php4/ext/pgsql/tests/config.inc <?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() ?> Index: php4/ext/pgsql/tests/connection.inc +++ php4/ext/pgsql/tests/connection.inc <?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"; ?> Index: php4/ext/pgsql/tests/copy.inc +++ php4/ext/pgsql/tests/copy.inc <?php include('config.inc'); echo "OK"; ?> Index: php4/ext/pgsql/tests/createdb.inc +++ php4/ext/pgsql/tests/createdb.inc <?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"; ?> Index: php4/ext/pgsql/tests/dropdb.inc +++ php4/ext/pgsql/tests/dropdb.inc <?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"; ?> Index: php4/ext/pgsql/tests/large_object.inc +++ php4/ext/pgsql/tests/large_object.inc <?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"; ?> Index: php4/ext/pgsql/tests/old_api.inc +++ php4/ext/pgsql/tests/old_api.inc <?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"; ?> Index: php4/ext/pgsql/tests/optional.inc +++ php4/ext/pgsql/tests/optional.inc <?php // optional functions include('config.inc'); $db = pg_connect($conn_str); $enc = pg_client_encoding($db); pg_set_client_encoding($db, $enc); echo "OK"; ?> Index: php4/ext/pgsql/tests/skipif.inc +++ php4/ext/pgsql/tests/skipif.inc <?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"); } ?> Index: php4/ext/pgsql/tests/sync_query.inc +++ php4/ext/pgsql/tests/sync_query.inc <?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"; ?>