summaryrefslogtreecommitdiff
path: root/ext/pgsql/tests
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-04-08 01:37:38 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-04-08 01:37:38 +0000
commit4ac70c6821545e824a78dd9341d8c66240b63583 (patch)
tree68f423b4b444d70303dccbef8c19b52bf8661338 /ext/pgsql/tests
parent7d48177f373bb484339fbeda5235ce6b32d44427 (diff)
downloadphp-git-4ac70c6821545e824a78dd9341d8c66240b63583.tar.gz
Added pg_metadate(), pg_convert(), pg_insert(), pg_select(), pg_update()
and pg_delete(). @ Added pg_metadate(), pg_convert(), pg_insert(), pg_select(), pg_update() @ and pg_delete(). (Yasuo)
Diffstat (limited to 'ext/pgsql/tests')
-rw-r--r--ext/pgsql/tests/10pg_convert.phpt17
-rw-r--r--ext/pgsql/tests/11pg_metadata.phpt51
-rw-r--r--ext/pgsql/tests/12pg_insert.phpt10
-rw-r--r--ext/pgsql/tests/13pg_select.phpt21
-rw-r--r--ext/pgsql/tests/14pg_update.phpt10
-rw-r--r--ext/pgsql/tests/15pg_delete.phpt10
-rw-r--r--ext/pgsql/tests/16pg_result_status.phpt11
-rw-r--r--ext/pgsql/tests/informational.inc47
-rw-r--r--ext/pgsql/tests/pg_convert.inc14
-rw-r--r--ext/pgsql/tests/pg_delete.inc17
-rw-r--r--ext/pgsql/tests/pg_insert.inc16
-rw-r--r--ext/pgsql/tests/pg_metadata.inc13
-rw-r--r--ext/pgsql/tests/pg_result_status.inc13
-rw-r--r--ext/pgsql/tests/pg_select.inc18
-rw-r--r--ext/pgsql/tests/pg_update.inc17
15 files changed, 285 insertions, 0 deletions
diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt
new file mode 100644
index 0000000000..ca54fdd50d
--- /dev/null
+++ b/ext/pgsql/tests/10pg_convert.phpt
@@ -0,0 +1,17 @@
+--TEST--
+PostgreSQL pg_convert()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_convert.inc");
+?>
+--EXPECT--
+array(3) {
+ ["num"]=>
+ int(1234)
+ ["str"]=>
+ string(5) "'AAA'"
+ ["bin"]=>
+ string(5) "'BBB'"
+}
diff --git a/ext/pgsql/tests/11pg_metadata.phpt b/ext/pgsql/tests/11pg_metadata.phpt
new file mode 100644
index 0000000000..08aab03a77
--- /dev/null
+++ b/ext/pgsql/tests/11pg_metadata.phpt
@@ -0,0 +1,51 @@
+--TEST--
+PostgreSQL pg_metadata()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_metadata.inc");
+?>
+--EXPECT--
+array(3) {
+ ["num"]=>
+ array(5) {
+ ["num"]=>
+ int(1)
+ ["type"]=>
+ string(4) "int4"
+ ["len"]=>
+ int(4)
+ ["not null"]=>
+ bool(false)
+ ["default"]=>
+ bool(false)
+ }
+ ["str"]=>
+ array(5) {
+ ["num"]=>
+ int(2)
+ ["type"]=>
+ string(4) "text"
+ ["len"]=>
+ int(-1)
+ ["not null"]=>
+ bool(false)
+ ["default"]=>
+ bool(false)
+ }
+ ["bin"]=>
+ array(5) {
+ ["num"]=>
+ int(3)
+ ["type"]=>
+ string(5) "bytea"
+ ["len"]=>
+ int(-1)
+ ["not null"]=>
+ bool(false)
+ ["default"]=>
+ bool(false)
+ }
+}
+
diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt
new file mode 100644
index 0000000000..8070df1539
--- /dev/null
+++ b/ext/pgsql/tests/12pg_insert.phpt
@@ -0,0 +1,10 @@
+--TEST--
+PostgreSQL pg_insert()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_insert.inc");
+?>
+--EXPECT--
+Ok
diff --git a/ext/pgsql/tests/13pg_select.phpt b/ext/pgsql/tests/13pg_select.phpt
new file mode 100644
index 0000000000..7c61436089
--- /dev/null
+++ b/ext/pgsql/tests/13pg_select.phpt
@@ -0,0 +1,21 @@
+--TEST--
+PostgreSQL pg_select()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_select.inc");
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(3) {
+ ["num"]=>
+ string(4) "1234"
+ ["str"]=>
+ string(3) "AAA"
+ ["bin"]=>
+ string(3) "BBB"
+ }
+}
+Ok
diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt
new file mode 100644
index 0000000000..da78eeac92
--- /dev/null
+++ b/ext/pgsql/tests/14pg_update.phpt
@@ -0,0 +1,10 @@
+--TEST--
+PostgreSQL pg_update()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_update.inc");
+?>
+--EXPECT--
+Ok
diff --git a/ext/pgsql/tests/15pg_delete.phpt b/ext/pgsql/tests/15pg_delete.phpt
new file mode 100644
index 0000000000..331e898383
--- /dev/null
+++ b/ext/pgsql/tests/15pg_delete.phpt
@@ -0,0 +1,10 @@
+--TEST--
+PostgreSQL pg_delete()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_delete.inc");
+?>
+--EXPECT--
+Ok
diff --git a/ext/pgsql/tests/16pg_result_status.phpt b/ext/pgsql/tests/16pg_result_status.phpt
new file mode 100644
index 0000000000..6faf849e7f
--- /dev/null
+++ b/ext/pgsql/tests/16pg_result_status.phpt
@@ -0,0 +1,11 @@
+--TEST--
+PostgreSQL pg_result_status()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include("pg_result_status.inc");
+?>
+--EXPECT--
+1
+COMMIT
diff --git a/ext/pgsql/tests/informational.inc b/ext/pgsql/tests/informational.inc
new file mode 100644
index 0000000000..120c61335b
--- /dev/null
+++ b/ext/pgsql/tests/informational.inc
@@ -0,0 +1,47 @@
+<?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";
+}
+
+echo pg_host($db);
+
+
+pg_close($db);
+
+echo "OK";
+
+?> \ No newline at end of file
diff --git a/ext/pgsql/tests/pg_convert.inc b/ext/pgsql/tests/pg_convert.inc
new file mode 100644
index 0000000000..ab6e95ff65
--- /dev/null
+++ b/ext/pgsql/tests/pg_convert.inc
@@ -0,0 +1,14 @@
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+$converted = pg_convert($db, $table_name, $fields);
+
+var_dump($converted);
+
+
+?>
diff --git a/ext/pgsql/tests/pg_delete.inc b/ext/pgsql/tests/pg_delete.inc
new file mode 100644
index 0000000000..33e001081b
--- /dev/null
+++ b/ext/pgsql/tests/pg_delete.inc
@@ -0,0 +1,17 @@
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
+$ids = array('num'=>'1234');
+if (!pg_delete($db, $table_name, $ids, 1)) {
+ echo "Error\n";
+}
+else {
+ echo "Ok\n";
+}
+
+?> \ No newline at end of file
diff --git a/ext/pgsql/tests/pg_insert.inc b/ext/pgsql/tests/pg_insert.inc
new file mode 100644
index 0000000000..bfb2e90e83
--- /dev/null
+++ b/ext/pgsql/tests/pg_insert.inc
@@ -0,0 +1,16 @@
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+if (!pg_insert($db, $table_name, $fields, 1, 0)) {
+ echo "Error\n";
+}
+else {
+ echo "Ok\n";
+}
+
+?>
diff --git a/ext/pgsql/tests/pg_metadata.inc b/ext/pgsql/tests/pg_metadata.inc
new file mode 100644
index 0000000000..16a2577e36
--- /dev/null
+++ b/ext/pgsql/tests/pg_metadata.inc
@@ -0,0 +1,13 @@
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$meta = pg_metadata($db, $table_name);
+
+var_dump($meta);
+
+
+?>
diff --git a/ext/pgsql/tests/pg_result_status.inc b/ext/pgsql/tests/pg_result_status.inc
new file mode 100644
index 0000000000..2c03e8966a
--- /dev/null
+++ b/ext/pgsql/tests/pg_result_status.inc
@@ -0,0 +1,13 @@
+<?php
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$sql = "SELECT * FROM ".$table_name." WHERE num = -2";
+$result = pg_query($db, "BEGIN;END");
+
+echo pg_result_status($result)."\n";
+echo pg_result_status($result, PGSQL_STATUS_STRING)."\n";
+
+
+?> \ No newline at end of file
diff --git a/ext/pgsql/tests/pg_select.inc b/ext/pgsql/tests/pg_select.inc
new file mode 100644
index 0000000000..04ca501deb
--- /dev/null
+++ b/ext/pgsql/tests/pg_select.inc
@@ -0,0 +1,18 @@
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
+$ids = array('num'=>'1234');
+if (!($res = pg_select($db, $table_name, $ids, 1))) {
+ echo "Error\n";
+}
+else {
+ var_dump($res);
+ echo "Ok\n";
+}
+
+?> \ No newline at end of file
diff --git a/ext/pgsql/tests/pg_update.inc b/ext/pgsql/tests/pg_update.inc
new file mode 100644
index 0000000000..6501c09af5
--- /dev/null
+++ b/ext/pgsql/tests/pg_update.inc
@@ -0,0 +1,17 @@
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'XXX', 'bin'=>'YYY');
+$ids = array('num'=>'1234');
+if (!pg_update($db, $table_name, $fields, $ids, 1, 0)) {
+ echo "Error\n";
+}
+else {
+ echo "Ok\n";
+}
+
+?>