cvs: php4 /pear/DB/tests db_factory.phpt errors.inc numrows.inc /pear/DB/tests/mysql 010.phpt /pear/DB/tests/pgsql 005.phpt 010.phpt
| From: | Stig Bakken | Date: | Fri, 15 Dec 2000 02:36:19 +0000 |
| Subject: | cvs: php4 /pear/DB/tests db_factory.phpt errors.inc numrows.inc /pear/DB/tests/mysql 010.phpt /pear/DB/tests/pgsql 005.phpt 010.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-3172@lists.php.net to get a copy of this message | ||
ssb Thu Dec 14 18:36:19 2000 EDT
Added files:
/php4/pear/DB/tests errors.inc
/php4/pear/DB/tests/mysql 010.phpt
/php4/pear/DB/tests/pgsql 010.phpt
Modified files:
/php4/pear/DB/tests db_factory.phpt numrows.inc
/php4/pear/DB/tests/pgsql 005.phpt
Log:
* implemented error mapping for postgres (very early version) and tests
for mysql and pgsql
# NB! suddenly two tests are broken for some reason: DB/tests/db_error2.phpt
# and tests/pear_error.phpt. The symptom is that objects created for
# testing method error handlers are empty (no methods, no properties).
# No time to investigate them right now.
Index: php4/pear/DB/tests/db_factory.phpt
diff -u php4/pear/DB/tests/db_factory.phpt:1.1 php4/pear/DB/tests/db_factory.phpt:1.2
--- php4/pear/DB/tests/db_factory.phpt:1.1 Fri Sep 8 19:39:56 2000
+++ php4/pear/DB/tests/db_factory.phpt Thu Dec 14 18:36:18 2000
@@ -41,6 +41,6 @@
testing mssql: object: db_mssql: (phptype=mssql, dbsyntax=mssql)
testing mysql: object: db_mysql: (phptype=mysql, dbsyntax=mysql)
testing oci8: object: db_oci8: (phptype=oci8, dbsyntax=oci8)
-testing odbc: object: db_odbc: (phptype=odbc, dbsyntax=unknown)
+testing odbc: object: db_odbc: (phptype=odbc, dbsyntax=sql92)
testing pgsql: object: db_pgsql: (phptype=pgsql, dbsyntax=pgsql)
testing sybase: object: db_sybase: (phptype=sybase, dbsyntax=sybase)
Index: php4/pear/DB/tests/numrows.inc
diff -u php4/pear/DB/tests/numrows.inc:1.2 php4/pear/DB/tests/numrows.inc:1.3
--- php4/pear/DB/tests/numrows.inc:1.2 Wed Dec 13 06:41:04 2000
+++ php4/pear/DB/tests/numrows.inc Thu Dec 14 18:36:18 2000
@@ -1,5 +1,14 @@
<?php
+function errhandler($obj)
+{
+ $msg = $obj->getMessage();
+ print "$msg";
+ if (substr($msg, -1) != "\n") {
+ print "\n";
+ }
+}
+
$dbh->setErrorHandling(PEAR_ERROR_DIE);
$sth = $dbh->query("SELECT a FROM phptest");
printf("%d\n", $sth->numRows());
@@ -13,7 +22,7 @@
printf("%d\n", $sth->numRows());
$sth = $dbh->query("SELECT a FROM phptest where a < 0");
printf("%d\n", $sth->numRows());
-$dbh->setErrorHandling(PEAR_ERROR_PRINT);
+$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "errhandler");
$test = $dbh->numRows(false);
?>
Index: php4/pear/DB/tests/pgsql/005.phpt
diff -u php4/pear/DB/tests/pgsql/005.phpt:1.2 php4/pear/DB/tests/pgsql/005.phpt:1.3
--- php4/pear/DB/tests/pgsql/005.phpt:1.2 Wed Dec 13 06:41:04 2000
+++ php4/pear/DB/tests/pgsql/005.phpt Thu Dec 14 18:36:18 2000
@@ -8,7 +8,6 @@
require "../sequences.inc";
?>
--EXPECT--
-DB Error: ERROR: db_seq_test.nextval: sequence does not exist
-
+DB Error: no such table
a=1
b=2
Index: php4/pear/DB/tests/errors.inc
+++ php4/pear/DB/tests/errors.inc
<?php
function errhandler($obj)
{
$msg = $obj->getMessage();
print " $msg";
if (substr($msg, -1) != "\n") {
print "\n";
}
}
$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "errhandler");
print "Trying to provoke DB_ERROR_NOSUCHTABLE\n";
$dbh->query("SELECT * FROM tableThatDoesNotExist");
print "Trying to provoke DB_ERROR_ALREADY_EXISTS\n";
$dbh->query("CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)");
print "Trying to provoke DB_ERROR_NOSUCHTABLE\n";
$dbh->query("DROP TABLE tableThatDoesNotExist");
print "Trying to provoke DB_ERROR_CONSTRAINT\n";
$dbh->setErrorHandling(PEAR_ERROR_RETURN);
$dbh->query("DROP TABLE a");
$dbh->query("DROP TABLE b");
$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "errhandler");
$dbh->query("CREATE TABLE a (a INTEGER NOT NULL, PRIMARY KEY(a))");
$dbh->query("CREATE TABLE b (b INTEGER REFERENCES a(a))");
$dbh->query("INSERT INTO a VALUES(1)");
$dbh->query("INSERT INTO b VALUES(2)");
$dbh->query("DROP TABLE a");
$dbh->query("DROP TABLE b");
print "Trying to provoke DB_ERROR_DIVZERO\n";
$dbh->query("SELECT 0/0");
print "Trying to provoke DB_ERROR_INVALID_NUMBER\n";
$dbh->query("UPDATE phptest SET a = 'abc' WHERE a = 42");
print "Trying to provoke DB_ERROR_NOSUCHFIELD\n";
$dbh->query("SELECT e FROM phptest");
print "Trying to provoke DB_ERROR_SYNTAX\n";
$dbh->query("SYNTAX TERROR");
?>
Index: php4/pear/DB/tests/mysql/010.phpt
+++ php4/pear/DB/tests/mysql/010.phpt
--TEST--
DB_mysql error mapping
--SKIPIF--
<?php require "skipif.inc"; ?>
--FILE--
<?php
require "connect.inc";
require "mktable.inc";
require "../errors.inc";
?>
--EXPECT--
Trying to provoke DB_ERROR_NOSUCHTABLE
DB Error: no such table
Trying to provoke DB_ERROR_ALREADY_EXISTS
DB Error: already exists
Trying to provoke DB_ERROR_NOSUCHTABLE
DB Error: no such table
Trying to provoke DB_ERROR_CONSTRAINT
Trying to provoke DB_ERROR_DIVZERO
Trying to provoke DB_ERROR_INVALID_NUMBER
Trying to provoke DB_ERROR_NOSUCHFIELD
DB Error: no such field
Trying to provoke DB_ERROR_SYNTAX
DB Error: syntax error
Index: php4/pear/DB/tests/pgsql/010.phpt
+++ php4/pear/DB/tests/pgsql/010.phpt
--TEST--
DB_pgsql error mapping
--SKIPIF--
<?php require "skipif.inc"; ?>
--FILE--
<?php
require "connect.inc";
require "mktable.inc";
require "../errors.inc";
?>
--EXPECT--
Trying to provoke DB_ERROR_NOSUCHTABLE
DB Error: no such table
Trying to provoke DB_ERROR_ALREADY_EXISTS
DB Error: already exists
Trying to provoke DB_ERROR_NOSUCHTABLE
DB Error: no such table
Trying to provoke DB_ERROR_CONSTRAINT
Trying to provoke DB_ERROR_DIVZERO
DB Error: division by zero
Trying to provoke DB_ERROR_INVALID_NUMBER
DB Error: invalid number
Trying to provoke DB_ERROR_NOSUCHFIELD
DB Error: no such field
Trying to provoke DB_ERROR_SYNTAX
DB Error: syntax error