yohgaki Fri Oct 18 03:52:10 2002 EDT Added files: /php4/ext/pgsql/tests 18pg_escape_bytea.phpt 19pg_ping.phpt 20pg_get_pid.phpt 21pg_get_notify.phpt README pg_escape_bytea.inc pg_get_notify.inc pg_get_pid.inc pg_ping.inc
Modified files: /php4/ext/pgsql/tests 17result.phpt createdb.inc large_object.inc result.inc Log: Added tests for new functions Index: php4/ext/pgsql/tests/17result.phpt diff -u php4/ext/pgsql/tests/17result.phpt:1.1 php4/ext/pgsql/tests/17result.phpt:1.2 --- php4/ext/pgsql/tests/17result.phpt:1.1 Thu Apr 25 03:52:01 2002 +++ php4/ext/pgsql/tests/17result.phpt Fri Oct 18 03:52:09 2002 @@ -37,4 +37,13 @@ [2]=> NULL } +array(3) { + ["num"]=> + string(1) "2" + ["str"]=> + string(3) "ABC" + ["bin"]=> + NULL +} +bool(true) Ok Index: php4/ext/pgsql/tests/createdb.inc diff -u php4/ext/pgsql/tests/createdb.inc:1.2 php4/ext/pgsql/tests/createdb.inc:1.3 --- php4/ext/pgsql/tests/createdb.inc:1.2 Fri Apr 5 01:06:21 2002 +++ php4/ext/pgsql/tests/createdb.inc Fri Oct 18 03:52:09 2002 @@ -6,7 +6,7 @@ $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');"); } Index: php4/ext/pgsql/tests/large_object.inc diff -u php4/ext/pgsql/tests/large_object.inc:1.3 php4/ext/pgsql/tests/large_object.inc:1.4 --- php4/ext/pgsql/tests/large_object.inc:1.3 Sat Apr 20 10:06:47 2002 +++ php4/ext/pgsql/tests/large_object.inc Fri Oct 18 03:52:09 2002 @@ -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_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_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 @@ 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"); @@ -43,6 +48,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"; Index: php4/ext/pgsql/tests/result.inc diff -u php4/ext/pgsql/tests/result.inc:1.1 php4/ext/pgsql/tests/result.inc:1.2 --- php4/ext/pgsql/tests/result.inc:1.1 Thu Apr 25 03:52:01 2002 +++ php4/ext/pgsql/tests/result.inc Fri Oct 18 03:52:09 2002 @@ -15,6 +15,9 @@ 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"; Index: php4/ext/pgsql/tests/18pg_escape_bytea.phpt +++ php4/ext/pgsql/tests/18pg_escape_bytea.phpt --TEST-- PostgreSQL pg_escape_bytea() functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("pg_escape_bytea.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/19pg_ping.phpt +++ php4/ext/pgsql/tests/19pg_ping.phpt --TEST-- PostgreSQL pg_ping() functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("pg_ping.inc"); ?> --EXPECT-- bool(true) Index: php4/ext/pgsql/tests/20pg_get_pid.phpt +++ php4/ext/pgsql/tests/20pg_get_pid.phpt --TEST-- PostgreSQL pg_get_pid() functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("pg_get_pid.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/21pg_get_notify.phpt +++ php4/ext/pgsql/tests/21pg_get_notify.phpt --TEST-- PostgreSQL pg_get_notify() functions --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include("pg_get_notify.inc"); ?> --EXPECT-- OK Index: php4/ext/pgsql/tests/pg_escape_bytea.inc +++ php4/ext/pgsql/tests/pg_escape_bytea.inc <?php // optional functions include('config.inc'); $fp = fopen('php.gif', 'r'); $image = fread($fp, filesize('php.gif')); $esc_image = pg_escape_bytea($image); $db = pg_connect($conn_str); pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');'); $result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876'); $rows = pg_fetch_all($result); $unesc_image = pg_unescape_bytea($rows[0]['bin']); if ($unesc_image !== $image) { echo "NG"; } else { echo "OK"; } ?> Index: php4/ext/pgsql/tests/pg_get_notify.inc +++ php4/ext/pgsql/tests/pg_get_notify.inc <?php // optional functions include('config.inc'); $db = pg_connect($conn_str); pg_query($db, 'LISTEN test_msg'); pg_query($db, 'NOTIFY test_msg'); $msg = pg_get_notify($db); isset($msg['message'],$msg['pid']) ? print 'OK' : print 'NG'; ?> Index: php4/ext/pgsql/tests/pg_get_pid.inc +++ php4/ext/pgsql/tests/pg_get_pid.inc <?php // optional functions include('config.inc'); $db = pg_connect($conn_str); $pid = pg_get_pid($db); is_integer($pid) ? print 'OK' : print 'NG'; ?> Index: php4/ext/pgsql/tests/pg_ping.inc +++ php4/ext/pgsql/tests/pg_ping.inc <?php // optional functions include('config.inc'); $db = pg_connect($conn_str); var_dump(pg_ping($db)); ?> -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php