diff options
author | Yasuo Ohgaki <yohgaki@php.net> | 2002-10-18 07:52:09 +0000 |
---|---|---|
committer | Yasuo Ohgaki <yohgaki@php.net> | 2002-10-18 07:52:09 +0000 |
commit | 5693bd4cdf2f8346d7bef96206583fa26225c1a8 (patch) | |
tree | 055d297de7916eec02b90ae012fa9ddb8732ea7c /ext/pgsql/tests | |
parent | 5b4b10c5eb859809aa747c9da441e4924e574823 (diff) | |
download | php-git-5693bd4cdf2f8346d7bef96206583fa26225c1a8.tar.gz |
Added tests for new functions
Diffstat (limited to 'ext/pgsql/tests')
-rw-r--r-- | ext/pgsql/tests/17result.phpt | 9 | ||||
-rw-r--r-- | ext/pgsql/tests/18pg_escape_bytea.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/19pg_ping.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/20pg_get_pid.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/21pg_get_notify.phpt | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/README | 14 | ||||
-rw-r--r-- | ext/pgsql/tests/createdb.inc | 2 | ||||
-rw-r--r-- | ext/pgsql/tests/large_object.inc | 18 | ||||
-rw-r--r-- | ext/pgsql/tests/pg_escape_bytea.inc | 25 | ||||
-rw-r--r-- | ext/pgsql/tests/pg_get_notify.inc | 16 | ||||
-rw-r--r-- | ext/pgsql/tests/pg_get_pid.inc | 13 | ||||
-rw-r--r-- | ext/pgsql/tests/pg_ping.inc | 10 | ||||
-rw-r--r-- | ext/pgsql/tests/result.inc | 3 |
13 files changed, 149 insertions, 1 deletions
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-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("pg_escape_bytea.inc"); +?> +--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-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("pg_ping.inc"); +?> +--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-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("pg_get_pid.inc"); +?> +--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-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("pg_get_notify.inc"); +?> +--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 @@ +<?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"; +} + + +?>
\ 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 @@ +<?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'; + + +?>
\ 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 @@ +<?php +// optional functions + +include('config.inc'); + + +$db = pg_connect($conn_str); +$pid = pg_get_pid($db); + +is_integer($pid) ? print 'OK' : print 'NG'; + + +?>
\ 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 @@ +<?php +// optional functions + +include('config.inc'); + +$db = pg_connect($conn_str); +var_dump(pg_ping($db)); + + +?>
\ 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"; |