cvs: php4 /ext/pgsql/tests 08escape.phpt 10pg_convert.phpt 11pg_metadata.phpt escape.inc
| From: | Yasuo Ohgaki | Date: | Fri, 19 Apr 2002 12:24:58 +0000 |
| Subject: | cvs: php4 /ext/pgsql/tests 08escape.phpt 10pg_convert.phpt 11pg_metadata.phpt escape.inc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-11233@lists.php.net to get a copy of this message | ||
yohgaki Fri Apr 19 08:24:58 2002 EDT
Modified files:
/php4/ext/pgsql/tests 08escape.phpt 10pg_convert.phpt
11pg_metadata.phpt escape.inc
Log:
Update tests
Index: php4/ext/pgsql/tests/08escape.phpt
diff -u php4/ext/pgsql/tests/08escape.phpt:1.3 php4/ext/pgsql/tests/08escape.phpt:1.4
--- php4/ext/pgsql/tests/08escape.phpt:1.3 Fri Apr 5 01:05:28 2002
+++ php4/ext/pgsql/tests/08escape.phpt Fri Apr 19 08:24:58 2002
@@ -7,6 +7,8 @@
include("escape.inc");
?>
--EXPECT--
-pg_escape_string() is Ok
+pg_escape_string() is NOT Ok
+string(9) "ABC\ABC\'"
+string(12) "ABC\\ABC\\''"
+string(10) "ABC\\ABC\'"
pg_escape_bytea() is Ok
-pg_escape_bytea() actually works with databse
Index: php4/ext/pgsql/tests/10pg_convert.phpt
diff -u php4/ext/pgsql/tests/10pg_convert.phpt:1.1 php4/ext/pgsql/tests/10pg_convert.phpt:1.2
--- php4/ext/pgsql/tests/10pg_convert.phpt:1.1 Sun Apr 7 21:37:38 2002
+++ php4/ext/pgsql/tests/10pg_convert.phpt Fri Apr 19 08:24:58 2002
@@ -9,7 +9,7 @@
--EXPECT--
array(3) {
["num"]=>
- int(1234)
+ string(4) "1234"
["str"]=>
string(5) "'AAA'"
["bin"]=>
Index: php4/ext/pgsql/tests/11pg_metadata.phpt
diff -u php4/ext/pgsql/tests/11pg_metadata.phpt:1.1 php4/ext/pgsql/tests/11pg_metadata.phpt:1.2
--- php4/ext/pgsql/tests/11pg_metadata.phpt:1.1 Sun Apr 7 21:37:38 2002
+++ php4/ext/pgsql/tests/11pg_metadata.phpt Fri Apr 19 08:24:58 2002
@@ -18,7 +18,7 @@
int(4)
["not null"]=>
bool(false)
- ["default"]=>
+ ["has default"]=>
bool(false)
}
["str"]=>
@@ -31,7 +31,7 @@
int(-1)
["not null"]=>
bool(false)
- ["default"]=>
+ ["has default"]=>
bool(false)
}
["bin"]=>
@@ -44,8 +44,7 @@
int(-1)
["not null"]=>
bool(false)
- ["default"]=>
+ ["has default"]=>
bool(false)
}
}
-
Index: php4/ext/pgsql/tests/escape.inc
diff -u php4/ext/pgsql/tests/escape.inc:1.4 php4/ext/pgsql/tests/escape.inc:1.5
--- php4/ext/pgsql/tests/escape.inc:1.4 Fri Apr 5 01:07:46 2002
+++ php4/ext/pgsql/tests/escape.inc Fri Apr 19 08:24:58 2002
@@ -32,25 +32,28 @@
}
// Test using database
-$fp = fopen(FILE_NAME,'r');
+$fp = fopen(FILE_NAME,'r');
$data = fread($fp, filesize(FILE_NAME));
+$db = pg_connect($conn_str);
-$db = pg_connect($conn_str);
+// Insert binary to DB
$escaped_data = pg_escape_bytea($data);
-//$out = fopen('php.gif_escaped','w');
-//fwrite($out, $escaped_data);
-//exit;
-pg_query("DELETE FROM ".$table_name." WHERE num = -2;");
-$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-2,
'".$escaped_data."');";
+pg_query("DELETE FROM ".$table_name." WHERE num = -9999;");
+$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST
('".$escaped_data."' AS BYTEA));";
pg_query($db, $sql);
-$sql = "SELECT * FROM ".$table_name." WHERE num = -2";
+
+// Retrieve binary from DB
+$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
$result = pg_query($db, $sql);
-$row = pg_fetch_row($result, 0);
-if ($data === $row['bin']) {
- echo "pg_escape_bytea() actually works with databse\n";
-}
-else {
- echo "pg_escape_bytea() is broken\n";
-}
+$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
+
+// Compare
+// Need to wait PostgreSQL 7.3.x for PQunescapeBytea()
+// if ($data === pg_unescape_bytea($row['bin'])) {
+// echo "pg_escape_bytea() actually works with databse\n";
+// }
+// else {
+// echo "pg_escape_bytea() is broken\n";
+// }
?>