cvs: pear /DB/DB/tests .cvsignore db_error.phpt db_error2.phpt db_factory.phpt db_ismanip.phpt db_parsedsn.phpt errors.inc fetchmode_object.inc
fetchmodes.inc fetchrow.inc limit.inc numcols.inc numrows.inc prepexe.inc sequences.inc simplequery.inc tableinfo.inc transactions.inc
/DB/DB/tests/driver .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt 13limit.phpt 14fetchmode_object.phpt 15quote.phpt connect.inc mktable.inc setup.inc skipif.inc /DB/DB/tests/ibase
.cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 10errormap.phpt connect.inc mktable.inc
skipif.inc /DB/DB/tests/mysql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt 14fetchmode_object.phpt connect.inc mktable.inc
skipif.inc /DB/DB/tests/oci8 .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt connect.inc mktable.inc skipif.inc
/DB/DB/tests/odbc .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 06prepexec.phpt 07errornative.phpt 09numrows.phpt
10errormap.phpt connect.inc dsn.inc mktable.inc skipif.inc /DB/DB/tests/pgsql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt
04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 11transact.phpt 13limit.phpt
14fetchmode_object.phpt connect.inc mktable.inc skipif.inc /DB/tests .cvsignore db_error.phpt db_error2.phpt db_factory.phpt db_ismanip.phpt
db_parsedsn.phpt errors.inc fetchmode_object.inc fetchmodes.inc fetchrow.inc limit.inc numcols.inc numrows.inc prepexe.inc sequences.inc
simplequery.inc tableinfo.inc transactions.inc /DB/tests/driver .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 13limit.phpt 14fetchmode_object.phpt 15quote.phpt connect.inc
mktable.inc setup.inc skipif.inc /DB/tests/ibase .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt
06prepexec.phpt 10errormap.phpt connect.inc mktable.inc skipif.inc /DB/tests/mysql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt
04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt
14fetchmode_object.phpt connect.inc mktable.inc skipif.inc /DB/tests/oci8 .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt connect.inc
mktable.inc skipif.inc /DB/tests/odbc .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 06prepexec.phpt 07errornative.phpt
09numrows.phpt 10errormap.phpt connect.inc dsn.inc mktable.inc skipif.inc /DB/tests/pgsql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt
04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 11transact.phpt 13limit.phpt
14fetchmode_object.phpt connect.inc mktable.inc skipif.inc
| From: | Stig Bakken | Date: | Sun, 12 May 2002 07:29:28 +0000 |
| Subject: | cvs: pear /DB/DB/tests .cvsignore db_error.phpt db_error2.phpt db_factory.phpt db_ismanip.phpt db_parsedsn.phpt errors.inc fetchmode_object.inc fetchmodes.inc fetchrow.inc limit.inc numcols.inc numrows.inc prepexe.inc sequences.inc simplequery.inc tableinfo.inc transactions.inc /DB/DB/tests/driver .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 13limit.phpt 14fetchmode_object.phpt 15quote.phpt connect.inc mktable.inc setup.inc skipif.inc /DB/DB/tests/ibase .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 10errormap.phpt connect.inc mktable.inc skipif.inc /DB/DB/tests/mysql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt 14fetchmode_object.phpt connect.inc mktable.inc skipif.inc /DB/DB/tests/oci8 .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt connect.inc mktable.inc skipif.inc /DB/DB/tests/odbc .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 06prepexec.phpt 07errornative.phpt 09numrows.phpt 10errormap.phpt connect.inc dsn.inc mktable.inc skipif.inc /DB/DB/tests/pgsql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 11transact.phpt 13limit.phpt 14fetchmode_object.phpt connect.inc mktable.inc skipif.inc /DB/tests .cvsignore db_error.phpt db_error2.phpt db_factory.phpt db_ismanip.phpt db_parsedsn.phpt errors.inc fetchmode_object.inc fetchmodes.inc fetchrow.inc limit.inc numcols.inc numrows.inc prepexe.inc sequences.inc simplequery.inc tableinfo.inc transactions.inc /DB/tests/driver .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 13limit.phpt 14fetchmode_object.phpt 15quote.phpt connect.inc mktable.inc setup.inc skipif.inc /DB/tests/ibase .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 10errormap.phpt connect.inc mktable.inc skipif.inc /DB/tests/mysql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt 14fetchmode_object.phpt connect.inc mktable.inc skipif.inc /DB/tests/oci8 .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 12tableinfo.phpt 13limit.phpt connect.inc mktable.inc skipif.inc /DB/tests/odbc .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 06prepexec.phpt 07errornative.phpt 09numrows.phpt 10errormap.phpt connect.inc dsn.inc mktable.inc skipif.inc /DB/tests/pgsql .cvsignore 01connect.phpt 02fetch.phpt 03simplequery.phpt 04numcols.phpt 05sequences.phpt 06prepexec.phpt 07errornative.phpt 08affectedrows.phpt 09numrows.phpt 10errormap.phpt 11transact.phpt 13limit.phpt 14fetchmode_object.phpt connect.inc mktable.inc skipif.inc |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3770@lists.php.net to get a copy of this message | ||
ssb Sun May 12 03:29:28 2002 EDT
Added files:
/pear/DB/tests/ibase 05sequences.phpt
/pear/DB/tests/oci8 12tableinfo.phpt
Removed files:
/pear/DB/DB/tests .cvsignore db_error.phpt db_error2.phpt
db_factory.phpt db_ismanip.phpt db_parsedsn.phpt
errors.inc fetchmode_object.inc fetchmodes.inc
fetchrow.inc limit.inc numcols.inc numrows.inc
prepexe.inc sequences.inc simplequery.inc
tableinfo.inc transactions.inc
/pear/DB/DB/tests/driver .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
08affectedrows.phpt 09numrows.phpt
10errormap.phpt 13limit.phpt
14fetchmode_object.phpt 15quote.phpt
connect.inc mktable.inc setup.inc
skipif.inc
/pear/DB/DB/tests/ibase .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
10errormap.phpt connect.inc mktable.inc
skipif.inc
/pear/DB/DB/tests/mysql .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt
12tableinfo.phpt 13limit.phpt
14fetchmode_object.phpt connect.inc
mktable.inc skipif.inc
/pear/DB/DB/tests/oci8 .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt
12tableinfo.phpt 13limit.phpt connect.inc
mktable.inc skipif.inc
/pear/DB/DB/tests/odbc .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
06prepexec.phpt 07errornative.phpt
09numrows.phpt 10errormap.phpt connect.inc
dsn.inc mktable.inc skipif.inc
/pear/DB/DB/tests/pgsql .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt
11transact.phpt 13limit.phpt
14fetchmode_object.phpt connect.inc
mktable.inc skipif.inc
Modified files:
/pear/DB/tests .cvsignore db_error.phpt db_error2.phpt
db_factory.phpt db_ismanip.phpt db_parsedsn.phpt
errors.inc fetchmode_object.inc fetchmodes.inc
fetchrow.inc limit.inc numcols.inc numrows.inc
prepexe.inc sequences.inc simplequery.inc
tableinfo.inc transactions.inc
/pear/DB/tests/driver .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
08affectedrows.phpt 09numrows.phpt
10errormap.phpt 13limit.phpt
14fetchmode_object.phpt 15quote.phpt
connect.inc mktable.inc setup.inc skipif.inc
/pear/DB/tests/ibase .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
06prepexec.phpt 10errormap.phpt connect.inc
mktable.inc skipif.inc
/pear/DB/tests/mysql .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt
12tableinfo.phpt 13limit.phpt
14fetchmode_object.phpt connect.inc
mktable.inc skipif.inc
/pear/DB/tests/oci8 .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt 13limit.phpt
connect.inc mktable.inc skipif.inc
/pear/DB/tests/odbc .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
06prepexec.phpt 07errornative.phpt
09numrows.phpt 10errormap.phpt connect.inc
dsn.inc mktable.inc skipif.inc
/pear/DB/tests/pgsql .cvsignore 01connect.phpt 02fetch.phpt
03simplequery.phpt 04numcols.phpt
05sequences.phpt 06prepexec.phpt
07errornative.phpt 08affectedrows.phpt
09numrows.phpt 10errormap.phpt 11transact.phpt
13limit.phpt 14fetchmode_object.phpt
connect.inc mktable.inc skipif.inc
Log:
* moved tests from DB/tests to tests
Index: pear/DB/tests/.cvsignore diff -u /dev/null pear/DB/tests/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/.cvsignore Sun May 12 03:29:24 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/db_error.phpt diff -u /dev/null pear/DB/tests/db_error.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_error.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,78 @@ +--TEST-- +DB_Error/DB_Warning test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB.php +// Parts tested: DB_Error, DB_Warning + +function test_error_handler($errno, $errmsg, $file, $line, $vars) { + $errortype = array ( + 1 => "Error", + 2 => "Warning", + 4 => "Parsing Error", + 8 => "Notice", + 16 => "Core Error", + 32 => "Core Warning", + 64 => "Compile Error", + 128 => "Compile Warning", + 256 => "User Error", + 512 => "User Warning", + 1024=> "User Notice" + ); + $prefix = $errortype[$errno]; + $file = basename($file); + print "\n$prefix: $errmsg in $file on line $line\n"; +} + +error_reporting(E_ALL); +set_error_handler("test_error_handler"); +require_once "DB.php"; + +print "testing different error codes...\n"; +$e = new DB_Error(); print $e->toString()."\n"; +$e = new DB_Error("test error"); print $e->toString()."\n"; +$e = new DB_Error(DB_OK); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR_SYNTAX); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR_DIVZERO); print $e->toString()."\n"; +$e = new DB_Warning(); print $e->toString()."\n"; +$e = new DB_Warning("test warning"); print $e->toString()."\n"; +$e = new DB_Warning(DB_WARNING_READ_ONLY); print $e->toString()."\n"; + +print "testing different error modes...\n"; +$e = new DB_Error(DB_ERROR, PEAR_ERROR_PRINT); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER); + +print "testing different error serverities...\n"; +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER, E_USER_NOTICE); +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER, E_USER_WARNING); +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER, E_USER_ERROR); + +?> +--GET-- +--POST-- +--EXPECT-- +testing different error codes... +[db_error: message="DB Error: unknown error" code=-1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: test error" code=-1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: no error" code=1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: unknown error" code=-1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: syntax error" code=-2 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: division by zero" code=-13 mode=return level=notice prefix="" info=""] +[db_warning: message="DB Warning: unknown warning" code=-1000 mode=return level=notice prefix="" info=""] +[db_warning: message="DB Warning: test warning" code=0 mode=return level=notice prefix="" info=""] +[db_warning: message="DB Warning: read only" code=-1001 mode=return level=notice prefix="" info=""] +testing different error modes... +DB Error: unknown error[db_error: message="DB Error: unknown error" code=-1 mode=print level=notice prefix="" info=""] + +User Notice: DB Error: syntax error in PEAR.php on line 591 +testing different error serverities... + +User Notice: DB Error: syntax error in PEAR.php on line 591 + +User Warning: DB Error: syntax error in PEAR.php on line 591 + +User Error: DB Error: syntax error in PEAR.php on line 591 Index: pear/DB/tests/db_error2.phpt diff -u /dev/null pear/DB/tests/db_error2.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_error2.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,76 @@ +--TEST-- +DB configurable error handler test +--FILE-- +<?php + +require_once "DB.php"; +error_reporting(4095); + +function myfunc(&$obj) { + print "myfunc here, obj=".$obj->toString()."\n"; +} +function myfunc2(&$obj) { + print "myfunc2 here, obj=".$obj->toString()."\n"; +} +class myclass { + function myfunc(&$obj) { + print "myclass::myfunc here, obj=".$obj->toString()."\n"; + } +} +function test_error_handler($errno, $errmsg, $file, $line, $vars) { + $errortype = array ( + 1 => "Error", + 2 => "Warning", + 4 => "Parsing Error", + 8 => "Notice", + 16 => "Core Error", + 32 => "Core Warning", + 64 => "Compile Error", + 128 => "Compile Warning", + 256 => "User Error", + 512 => "User Warning", + 1024=> "User Notice" + ); + $prefix = $errortype[$errno]; + $file = basename($file); + print "$prefix: $errmsg in $file on line $line\n"; +} + +$obj = new myclass; + +$dbh = DB::factory("mysql"); + +print "default: "; +$e = $dbh->raiseError("return testing error"); +print $e->toString() . "\n"; + +print "global default: "; +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "myfunc2"); +$e = $dbh->raiseError("global default test"); + +$dbh->setErrorHandling(PEAR_ERROR_PRINT); +print "mode=print: "; +$e = $dbh->raiseError("print testing error"); +print "\n"; + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "myfunc"); +print "mode=function callback: "; +$e = $dbh->raiseError("function callback testing error"); + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($obj, "myfunc")); +print "mode=object callback: "; +$e = $dbh->raiseError("object callback testing error"); + +set_error_handler("test_error_handler"); +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +print "mode=trigger: "; +$e = $dbh->raiseError("trigger testing error"); + +?> +--EXPECT-- +default: [db_error: message="DB Error: return testing error" code=-1 mode=return level=notice prefix="" info=""] +global default: myfunc2 here, obj=[db_error: message="DB Error: global default test" code=-1 mode=callback callback=myfunc2 prefix="" info=""] +mode=print: DB Error: print testing error +mode=function callback: myfunc here, obj=[db_error: message="DB Error: function callback testing error" code=-1 mode=callback callback=myfunc prefix="" info=""] +mode=object callback: myclass::myfunc here, obj=[db_error: message="DB Error: object callback testing error" code=-1 mode=callback callback=myclass::myfunc prefix="" info=""] +mode=trigger: User Notice: DB Error: trigger testing error in PEAR.php on line 591 Index: pear/DB/tests/db_factory.phpt diff -u /dev/null pear/DB/tests/db_factory.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_factory.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,46 @@ +--TEST-- +DB::factory test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB.php +// Parts tested: DB_Error, DB_Warning + +require_once "DB.php"; + +$backends = array( + "ibase", + "msql", + "mssql", + "mysql", + "oci8", + "odbc", + "pgsql", + "sybase" +); + +reset($backends); +while (list($i, $name) = each($backends)) { + print "testing $name: "; + $obj = DB::factory($name); + if (DB::isError($obj)) { + print "error: ".$obj->getMessage()."\n"; + } else { + print "object: ".$obj->toString()."\n"; + } +} + +?> +--GET-- +--POST-- +--EXPECT-- +testing ibase: object: db_ibase: (phptype=ibase, dbsyntax=ibase) +testing msql: object: db_msql: (phptype=msql, dbsyntax=msql) +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=sql92) +testing pgsql: object: db_pgsql: (phptype=pgsql, dbsyntax=pgsql) +testing sybase: object: db_sybase: (phptype=sybase, dbsyntax=sybase) Index: pear/DB/tests/db_ismanip.phpt diff -u /dev/null pear/DB/tests/db_ismanip.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_ismanip.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,60 @@ +--TEST-- +DB::isManip test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB.php +// Parts tested: DB::isManip + +require_once "DB.php"; + +function test($query) { + printf("%s : %d\n", preg_replace('/\s+.*/', '', $query), + DB::isManip($query)); +} + +print "testing DB::isManip...\n"; + +test("SELECT * FROM table"); +test("Select * from table"); +test("select * From table"); +test("sElECt * frOm table"); +test("SELECT DISTINCT name FROM table"); +test("UPDATE table SET foo = 'bar'"); +test("DELETE FROM table"); +test("delete from table where id is null"); +test("create table (id integer, name varchar(100))"); +test("CREATE SEQUENCE foo"); +test("\"CREATE PROCEDURE foo\""); +test("GRANT SELECT ON table TO user"); +test("REVOKE SELECT ON table FROM user"); +test("SHOW OPTIONS"); +test("DROP TABLE foo"); +test("ALTER TABLE foo ADD COLUMN (bar INTEGER)"); +test(" SELECT * FROM table"); +test(" DELETE FROM table"); +?> +--GET-- +--POST-- +--EXPECT-- +testing DB::isManip... +SELECT : 0 +Select : 0 +select : 0 +sElECt : 0 +SELECT : 0 +UPDATE : 1 +DELETE : 1 +delete : 1 +create : 1 +CREATE : 1 +"CREATE : 1 +GRANT : 1 +REVOKE : 1 +SHOW : 0 +DROP : 1 +ALTER : 1 + : 0 + : 1 Index: pear/DB/tests/db_parsedsn.phpt diff -u /dev/null pear/DB/tests/db_parsedsn.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_parsedsn.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,311 @@ +--TEST-- +DB::parseDSN test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB::parseDSN() + +include_once dirname(__FILE__)."/../../DB.php"; + +function test($dsn) { + echo "DSN: $dsn\n"; + print_r(DB::parseDSN($dsn)); +} + +print "testing DB::parseDSN...\n\n"; + +test("mysql"); +test("odbc(mssql)"); +test("mysql://localhost"); +test("mysql://remote.host.com/db"); +test("oci8://system:manager@"); +test("oci8://user:pass@tns-name"); +test("odbc(solid)://foo:bar@tcp+localhost+1313"); // deprecated +test("pgsql://user@unix+localhost/pear"); // deprecated +test("ibase://user%40domain:password@host"); +test("ibase://user@domain:pass@word@/database"); // also supported +test("ifx://user@domain:pass@word@host.com//usr/db/general.db"); +test('ifx://remote.host.com/c:\windows\my.db'); + +// new formats +test("odbc(solid)://foo:bar@localhost:1313"); +test("pgsql://user@unix()/pear"); +test("mysql://user@unix(/path/to/socket)/pear"); +test("pgsql://user@tcp()/pear"); +test("pgsql://user@tcp(somehost)/pear"); +test("pgsql://user:pass@word@tcp(somehost:7777)/pear"); + +// special backend options +test('ibase://user:pass@localhost//var/lib/dbase.dbf?role=foo'); +test('dbase://@/?role=foo&dialect=bar'); +?> +--GET-- +--POST-- +--EXPECT-- +testing DB::parseDSN... + +DSN: mysql +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => + [password] => + [protocol] => + [hostspec] => + [port] => + [socket] => + [database] => +) +DSN: odbc(mssql) +Array +( + [phptype] => odbc + [dbsyntax] => mssql + [username] => + [password] => + [protocol] => + [hostspec] => + [port] => + [socket] => + [database] => +) +DSN: mysql://localhost +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => + [password] => + [protocol] => tcp + [hostspec] => localhost + [port] => + [socket] => + [database] => +) +DSN: mysql://remote.host.com/db +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => + [password] => + [protocol] => tcp + [hostspec] => remote.host.com + [port] => + [socket] => + [database] => db +) +DSN: oci8://system:manager@ +Array +( + [phptype] => oci8 + [dbsyntax] => oci8 + [username] => system + [password] => manager + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => +) +DSN: oci8://user:pass@tns-name +Array +( + [phptype] => oci8 + [dbsyntax] => oci8 + [username] => user + [password] => pass + [protocol] => tcp + [hostspec] => tns-name + [port] => + [socket] => + [database] => +) +DSN: odbc(solid)://foo:bar@tcp+localhost+1313 +Array +( + [phptype] => odbc + [dbsyntax] => solid + [username] => foo + [password] => bar + [protocol] => tcp + [hostspec] => localhost 1313 + [port] => + [socket] => + [database] => +) +DSN: pgsql://user@unix+localhost/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => unix + [hostspec] => + [port] => + [socket] => localhost + [database] => pear +) +DSN: ibase://user%40domain:password@host +Array +( + [phptype] => ibase + [dbsyntax] => ibase + [username] => user@domain + [password] => password + [protocol] => tcp + [hostspec] => host + [port] => + [socket] => + [database] => +) +DSN: ibase://user@domain:pass@word@/database +Array +( + [phptype] => ibase + [dbsyntax] => ibase + [username] => user@domain + [password] => pass@word + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => database +) +DSN: ifx://user@domain:pass@word@host.com//usr/db/general.db +Array +( + [phptype] => ifx + [dbsyntax] => ifx + [username] => user@domain + [password] => pass@word + [protocol] => tcp + [hostspec] => host.com + [port] => + [socket] => + [database] => /usr/db/general.db +) +DSN: ifx://remote.host.com/c:\windows\my.db +Array +( + [phptype] => ifx + [dbsyntax] => ifx + [username] => + [password] => + [protocol] => tcp + [hostspec] => remote.host.com + [port] => + [socket] => + [database] => c:\windows\my.db +) +DSN: odbc(solid)://foo:bar@localhost:1313 +Array +( + [phptype] => odbc + [dbsyntax] => solid + [username] => foo + [password] => bar + [protocol] => tcp + [hostspec] => localhost + [port] => 1313 + [socket] => + [database] => +) +DSN: pgsql://user@unix()/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => unix + [hostspec] => + [port] => + [socket] => + [database] => pear +) +DSN: mysql://user@unix(/path/to/socket)/pear +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => user + [password] => + [protocol] => unix + [hostspec] => + [port] => + [socket] => /path/to/socket + [database] => pear +) +DSN: pgsql://user@tcp()/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => pear +) +DSN: pgsql://user@tcp(somehost)/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => tcp + [hostspec] => somehost + [port] => + [socket] => + [database] => pear +) +DSN: pgsql://user:pass@word@tcp(somehost:7777)/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => pass@word + [protocol] => tcp + [hostspec] => somehost + [port] => 7777 + [socket] => + [database] => pear +) +DSN: ibase://user:pass@localhost//var/lib/dbase.dbf?role=foo +Array +( + [phptype] => ibase + [dbsyntax] => ibase + [username] => user + [password] => pass + [protocol] => tcp + [hostspec] => localhost + [port] => + [socket] => + [database] => /var/lib/dbase.dbf + [role] => foo +) +DSN: dbase://@/?role=foo&dialect=bar +Array +( + [phptype] => dbase + [dbsyntax] => dbase + [username] => + [password] => + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => + [role] => foo + [dialect] => bar +) Index: pear/DB/tests/errors.inc diff -u /dev/null pear/DB/tests/errors.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/errors.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,49 @@ +<?php + +function errhandler($obj) +{ + if ($obj->getCode() == DB_ERROR) { + print " unknown: ".$obj->getUserInfo()."\n"; + } else { + $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($test_mktable_query); + +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 b"); +$dbh->query("DROP TABLE a"); +$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)"); + +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: pear/DB/tests/fetchmode_object.inc diff -u /dev/null pear/DB/tests/fetchmode_object.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/fetchmode_object.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,42 @@ +<?php +error_reporting(E_ALL); +function pe($obj) { + die($obj->getMessage() . "\n" . $obj->getDebugInfo()); +} + +function print_obj(&$obj) { + if (!is_object($obj)) { + echo "ERROR: no object!\n"; + } else { + echo get_class($obj) . " -> " . implode(" ", array_keys((array)$obj)) . "\n"; + } +} + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe'); + +echo "--- fetch with param DB_FETCHMODE_OBJECT ---\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(DB_FETCHMODE_OBJECT); +print_obj($row); +$sth = $dbh->query("SELECT * FROM phptest"); +$sth->fetchInto($row, DB_FETCHMODE_OBJECT); +print_obj($row); + +echo "--- fetch with default fetchmode DB_FETCHMODE_OBJECT ---\n"; +$dbh->setFetchMode(DB_FETCHMODE_OBJECT); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print_obj($row); +$sth = $dbh->query("SELECT * FROM phptest"); +$sth->fetchInto($row); +print_obj($row); + +echo "--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row ---\n"; +$dbh->setFetchMode(DB_FETCHMODE_OBJECT, 'DB_Row'); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print_obj($row); +$sth = $dbh->query("SELECT * FROM phptest"); +$sth->fetchInto($row); +print_obj($row); +?> \ No newline at end of file Index: pear/DB/tests/fetchmodes.inc diff -u /dev/null pear/DB/tests/fetchmodes.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/fetchmodes.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,68 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); + +print "testing fetchmodes: fetchrow default default\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto default default\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow ordered default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow assoc default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow ordered default with assoc specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(DB_FETCHMODE_ASSOC); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow assoc default with ordered specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(DB_FETCHMODE_ORDERED); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto ordered default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto assoc default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto ordered default with assoc specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row, DB_FETCHMODE_ASSOC); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto assoc default with ordered specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row, DB_FETCHMODE_ORDERED); +print implode(" ", array_keys($row))."\n"; + +?> Index: pear/DB/tests/fetchrow.inc diff -u /dev/null pear/DB/tests/fetchrow.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/fetchrow.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,26 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$dbh->query("INSERT INTO phptest VALUES(1, 'one', 'One', '2001-02-16')"); +$dbh->query("INSERT INTO phptest VALUES(2, 'two', 'Two', '2001-02-15')"); +$dbh->query("INSERT INTO phptest VALUES(3, 'three', 'Three', '2001-02-14')"); + +print "testing fetchrow:\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +for ($i = 1; $i <= 5; $i++) { + print "row $i: "; + $row = $sth->fetchRow(); + if (DB::isError($row)) { + print $row->toString() . "\n"; + continue; + } + if (is_array($row)) { + print implode(", ", $row) . "\n"; + } else { + var_dump($row); + } +} + +$dbh->query("DELETE FROM phptest WHERE a <> 42"); + +?> Index: pear/DB/tests/limit.inc diff -u /dev/null pear/DB/tests/limit.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/limit.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,33 @@ +<?php +error_reporting(E_ALL); +function pe($obj) { + die($obj->getMessage() . "\n" . $obj->getDebugInfo()); +} +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE php_limit"); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe'); +$dbh->query("CREATE TABLE php_limit (a VARCHAR(20))"); +$from = 0; +$count = 10; +$numrows = 30; + +for ($i=0; $i<=$numrows+2; $i++) { + $dbh->query("INSERT INTO php_limit VALUES('result $i')"); +} +// Hack for upper case col returned by Oracle +if ($dbh->dsn['phptype'] == 'oci8' && + $dbh->options['optimize'] != 'portability') { + $key = 'A'; +} else { + $key = 'a'; +} +for ($i = 0; $i <= 3; $i++) { + $from = 10 * $i; + $res = $dbh->limitQuery("select * from php_limit", $from, $count); + echo "======= From: $from || Number of rows to fetch: $count =======\n"; + while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { + echo $res->getRowCounter() . '.- ' . $row[$key] . "\n"; + } +} +//$dbh->query("DROP TABLE php_limit"); +?> \ No newline at end of file Index: pear/DB/tests/numcols.inc diff -u /dev/null pear/DB/tests/numcols.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/numcols.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,13 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$sth = $dbh->query("SELECT a FROM phptest"); +printf("%d\n", $sth->numCols()); +$sth = $dbh->query("SELECT a,b FROM phptest"); +printf("%d\n", $sth->numCols()); +$sth = $dbh->query("SELECT a,b,c FROM phptest"); +printf("%d\n", $sth->numCols()); +$sth = $dbh->query("SELECT * FROM phptest"); +printf("%d\n", $sth->numCols()); + +?> Index: pear/DB/tests/numrows.inc diff -u /dev/null pear/DB/tests/numrows.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/numrows.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,44 @@ +<?php + +if (!function_exists("errhandler")) +{ + function errhandler($obj) + { + printf("%s\n", $obj->getMessage()); + } +} + +if (isset($test_error_mode)) { + $dbh->setErrorHandling($test_error_mode); +} else { + $dbh->setErrorHandling(PEAR_ERROR_DIE); +} +$sth = $dbh->query("SELECT a FROM phptest"); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; +} else { + print "\n"; +} +for ($i = 0; $i < 5; $i++) { + $sth = $dbh->query("INSERT INTO phptest (a) VALUES($i)"); + $sth = $dbh->query("SELECT a FROM phptest"); + if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; + } else { + print "\n"; + } +} +$dbh->query("DELETE FROM phptest WHERE a < 4"); +$sth = $dbh->query("SELECT a FROM phptest"); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; +} else { + print "\n"; +} +$sth = $dbh->query("SELECT a FROM phptest where a < 0"); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; +} else { + print "\n"; +} +?> Index: pear/DB/tests/prepexe.inc diff -u /dev/null pear/DB/tests/prepexe.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/prepexe.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,33 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$sth1 = $dbh->prepare("INSERT INTO phptest (a) VALUES(?)"); +$sth2 = $dbh->prepare("INSERT INTO phptest (a,b) VALUES(?,?)"); +$sth3 = $dbh->prepare("INSERT INTO phptest (a,b,c) VALUES(?,?,&)"); +print "sth1,sth2,sth3 created\n"; +$tmpfile = tempnam("/tmp", "phptmp"); +register_shutdown_function("my_shutdown"); +$fp = fopen($tmpfile, "w"); +fwrite($fp, "opaque\nplaceholder\ntest"); +fclose($fp); +if (($res = $dbh->execute($sth1, array(72))) == DB_OK) { + print "sth1 executed\n"; +} +if (($res = $dbh->execute($sth2, array(72,'bing'))) == DB_OK) { + print "sth2 executed\n"; +} +if (($res = $dbh->execute($sth3, array(72,'gazonk',$tmpfile))) == DB_OK) { + print "sth3 executed\n"; +} +print "results:\n"; +$sth = $dbh->query("SELECT * FROM phptest WHERE a = 72"); +while ($row = $sth->fetchRow(DB_FETCHMODE_ORDERED)) { + print implode(" - ", $row) . "\n"; +} + +function my_shutdown() { + global $tmpfile; + unlink($tmpfile); +} + +?> Index: pear/DB/tests/sequences.inc diff -u /dev/null pear/DB/tests/sequences.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/sequences.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,79 @@ +<?php // -*- PHP -*- + +function error_handler(&$obj) { + print "sequences.inc error_handler\n"; +} +ob_implicit_flush(true); +$dbh->dropSequence("test"); + +// 1) test that sequences are not created if "ondemand" is false + +$e = $dbh->nextId("test", false); +if (DB::isError($e)) { + print $e->getMessage() . "\n"; +} else { + print "test 1) failed!\n"; +} + +// 2) test that the sequence is not created but the error is +// handled by the class error handler +$dbh->setErrorHandling(PEAR_ERROR_PRINT, "%s <- good error catched\n"); +$e = $dbh->nextId("test", false); +if (!DB::isError($e)) { + print "test 2) failed!\n"; +} +$dbh->_default_error_mode = null; + +// 3) test that sequences are created if "ondemand" is true, and that +// two successive nextIds return adjacent values +$a = $dbh->nextId("test"); +$b = $dbh->nextId("test"); +if (DB::isError($a)) { + print "a: ".$a->toString()."\n"; +} else { + print "a=$a\n"; +} +if (DB::isError($b)) { + print "b: ".$b->toString()."\n"; +} else { + print "b=$b\n"; +} +print "b-a=".($b-$a)."\n"; + +// 4) test that the user-specified error handler is really disabled +// during nextId, with per-object handler as well as global handler +$dbh->dropSequence("test"); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "error_handler"); +$c = $dbh->nextId("test"); +if (DB::isError($c)) { + print "c: ".$c->toString()."\n"; +} else { + print "c=$c\n"; +} +$dbh->dropSequence("test"); +$dbh->_default_error_mode = null; +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "error_handler"); +$d = $dbh->nextId("test"); +if (DB::isError($d)) { + print "d: ".$d->toString()."\n"; +} else { + print "d=$d\n"; +} + +// 5) test that the sequence is handled right when the table is empty + +// Backend with real sequences may don't like that +PEAR::pushErrorHandling(PEAR_ERROR_RETURN); +$dbh->query('DELETE FROM test_seq'); +PEAR::popErrorHandling(); +$e = $dbh->nextID('test'); +if (DB::isError($d)) { + print "e: ".$d->toString()."\n"; +} else { + print "e=$d\n"; +} + +// final clean-up +$dbh->dropSequence("test"); + +?> Index: pear/DB/tests/simplequery.inc diff -u /dev/null pear/DB/tests/simplequery.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/simplequery.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,7 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$sth = $dbh->simpleQuery("SELECT * FROM phptest"); +print gettype($sth)."\n"; + +?> Index: pear/DB/tests/tableinfo.inc diff -u /dev/null pear/DB/tests/tableinfo.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/tableinfo.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,91 @@ +<?php +function pe($o){ + die($o->toString()); +} +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest_fk"); + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK,'pe'); + +$dbh->query("DELETE FROM phptest"); +$dbh->query("INSERT INTO phptest VALUES(1, 'one', 'One', '2001-02-16')"); +$dbh->query("INSERT INTO phptest VALUES(2, 'two', 'Two', '2001-02-15')"); +$dbh->query("INSERT INTO phptest VALUES(3, 'three', 'Three', '2001-02-14')"); + +$test_mktable_query2 = "CREATE TABLE phptest_fk (a INTEGER, fk INTEGER, c TEXT, d DATE)"; +$dbh->query($test_mktable_query2); + +$dbh->query("INSERT INTO phptest_fk VALUES(1, 1, 'One', '2001-02-16')"); +$dbh->query("INSERT INTO phptest_fk VALUES(2, 1, ' Two', '2001-02-15')"); +$dbh->query("INSERT INTO phptest_fk VALUES(3, 2, 'Three', '2001-02-14')"); + + + +print "testing tableInfo:\n"; +$sth = $dbh->query("SELECT * FROM phptest left join phptest_fk on phptest.a = phptest_fk.fk"); + +$tableInfo = $sth->tableInfo(); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\neight (last) field:\n"; +print_foreach($tableInfo[7]) ; + +print "\ntesting tableInfo (DB_TABLEINFO_ORDER):\n"; +$tableInfo =$sth->tableInfo(DB_TABLEINFO_ORDER); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\neight field:\n"; +print_foreach($tableInfo[3]) ; +print "\nnum_fields:\n"; +print "$tableInfo[num_fields]\n" ; +print "\norder:\n"; +print_foreach($tableInfo['order']) ; + +print "\ntesting tableInfo (DB_TABLEINFO_ORDERTABLE):\n"; +$tableInfo =$sth->tableInfo(DB_TABLEINFO_ORDERTABLE); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\neight field:\n"; +print_foreach($tableInfo[3]) ; +print "\nnum_fields:\n"; +print "$tableInfo[num_fields]\n" ; +print "\nordertable:\n"; +print_foreach($tableInfo['ordertable']) ; +print "\nordertable[phptest]:\n"; +print_foreach($tableInfo['ordertable']['phptest']) ; +print "\nordertable[phptest_fk]:\n"; +print_foreach($tableInfo['ordertable']['phptest_fk']) ; + +print "\ntesting tableInfo (table without query-result):\n"; + +$tableInfo = $dbh->tableInfo("phptest"); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\nfourth (last) field:\n"; +print_foreach($tableInfo[3]) ; + +print "\ntesting tableInfo (table without query-result and DB_TABLEINFO_FULL):\n"; + +$tableInfo = $dbh->tableInfo("phptest",DB_TABLEINFO_FULL); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\norder:\n"; +print_foreach($tableInfo['order']) ; +print "\nordertable:\n"; +print_foreach($tableInfo['ordertable']) ; +print "\nordertable[phptest]:\n"; +print_foreach($tableInfo['ordertable']['phptest']) ; + + + +//print_foreach($tableInfo[0]) ; +$dbh->query("DELETE FROM phptest WHERE a <> 42"); +$dbh->query("DROP TABLE phptest_fk"); + +function print_foreach ($array) { + foreach ($array as $key => $value) { + print "$key => $value \n"; + } + +} +?> Index: pear/DB/tests/transactions.inc diff -u /dev/null pear/DB/tests/transactions.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/transactions.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,52 @@ +<?php + +// View the table from a separate connection so we don't disturb +// the transaction. +$dbh2 = DB::connect($dbh->dsn); + +function dumptable() { + global $dbh, $dbh2; + printf("%s ops=%d\n", implode(" ", $dbh->getCol("SELECT b FROM phptest")), + $dbh->transaction_opcount); +} +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$dbh->autoCommit(true); +$dbh->query("INSERT INTO phptest VALUES(1, 'one', 'One', '2001-02-19')"); +print "after autocommit: "; +dumptable(); +$dbh->autoCommit(false); +$dbh->query("INSERT INTO phptest VALUES(2, 'two', 'Two', '2001-02-20')"); +$dbh->query("INSERT INTO phptest VALUES(3, 'three', 'Three', '2001-02-21')"); +print "before commit: "; +dumptable(); +$dbh->commit(); +print "after commit: "; +dumptable(); +$dbh->query("INSERT INTO phptest VALUES(4, 'four', 'Four', '2001-02-22')"); +$dbh->query("INSERT INTO phptest VALUES(5, 'five', 'Five', '2001-02-23')"); +print "before rollback: "; +dumptable(); +$dbh->rollback(); +print "after rollback: "; +dumptable(); +$dbh->autoCommit(true); +$dbh->query("INSERT INTO phptest VALUES(6, 'six', 'Six', '2001-02-24')"); +$dbh->query("INSERT INTO phptest VALUES(7, 'seven', 'Seven', '2001-02-25')"); +print "before autocommit+rollback: "; +dumptable(); +$dbh->rollback(); +print "after autocommit+rollback: "; +dumptable(); + +print "testing that select doesn't disturbe opcount: "; +$dbh->autoCommit(false); +$dbh->simpleQuery("SELECT * FROM phptest"); +$dbh->simpleQuery("SELECT a,c FROM phptest"); +$dbh->simpleQuery("SELECT b,d FROM phptest"); +if ($dbh->transaction_opcount == 0) { + print "ok\n"; +} else { + print "failed (count=$dbh->transaction_opcount)\n"; +} + +?> Index: pear/DB/tests/driver/.cvsignore diff -u /dev/null pear/DB/tests/driver/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/.cvsignore Sun May 12 03:29:24 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/driver/01connect.phpt diff -u /dev/null pear/DB/tests/driver/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/01connect.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_driver::connect test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/driver/02fetch.phpt diff -u /dev/null pear/DB/tests/driver/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/02fetch.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,37 @@ +--TEST-- +DB_driver::fetch test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/driver/03simplequery.phpt diff -u /dev/null pear/DB/tests/driver/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/03simplequery.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,11 @@ +--TEST-- +DB_driver::simpleQuery test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/driver/04numcols.phpt diff -u /dev/null pear/DB/tests/driver/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/04numcols.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,14 @@ +--TEST-- +DB_driver::numCols test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/driver/05sequences.phpt diff -u /dev/null pear/DB/tests/driver/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/05sequences.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,18 @@ +--TEST-- +DB_driver::sequences +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +DB Error: no such table <- good error catched +a=1 +b=2 +b-a=1 +c=1 +d=1 +e=1 Index: pear/DB/tests/driver/06prepexec.phpt diff -u /dev/null pear/DB/tests/driver/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/06prepexec.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,20 @@ +--TEST-- +DB_driver::prepare/execute test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/driver/08affectedrows.phpt diff -u /dev/null pear/DB/tests/driver/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/08affectedrows.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,34 @@ +--TEST-- +DB_driver::affectedRows test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +// Clean table +$dbh->query("DELETE FROM phptest"); + +// Affected rows by INSERT statement +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); + +// Affected rows by SELECT statement +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); + +// Affected rows by DELETE statement +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->setOption("optimize", "portability"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all (optimize=%s)\n", $dbh->affectedRows(), + $dbh->getOption("optimize")); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +2 after delete all (optimize=portability) Index: pear/DB/tests/driver/09numrows.phpt diff -u /dev/null pear/DB/tests/driver/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/09numrows.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_driver::numRows test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 Index: pear/DB/tests/driver/10errormap.phpt diff -u /dev/null pear/DB/tests/driver/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/10errormap.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,27 @@ +--TEST-- +DB_driver::error mapping +--SKIPIF-- +<?php chdir(dirname(__FILE__)); 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 + DB Error: constraint violation +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 Index: pear/DB/tests/driver/13limit.phpt diff -u /dev/null pear/DB/tests/driver/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/13limit.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_driver::row limit +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include '../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/driver/14fetchmode_object.phpt diff -u /dev/null pear/DB/tests/driver/14fetchmode_object.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/14fetchmode_object.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_driver::fetchmode object +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require './connect.inc'; +include '../fetchmode_object.inc'; +?> +--EXPECT-- +--- fetch with param DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row --- +db_row -> a b c d +db_row -> a b c d Index: pear/DB/tests/driver/15quote.phpt diff -u /dev/null pear/DB/tests/driver/15quote.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/15quote.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,67 @@ +--TEST-- +DB_driver::escape data test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include './connect.inc'; +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'debug_die'); + +$dbh->expectError(DB_ERROR_ALREADY_EXISTS); +$dbh->query("CREATE TABLE pearquote (n FLOAT, s VARCHAR(8))"); +$dbh->popExpect(); + +$dbh->query("DELETE FROM pearquote"); + +$strings = array( + "'", + "\"", + "\\", + "%", + "_", + "''", + "\"\"", + "\\\\", + "\\'\\'", + "\\\"\\\"" +); +$nums = array( + 156, + 12.3, + '15', + '12.3' +); + +echo "String escape test: "; +foreach ($strings as $s) { + $quoted = $dbh->quote($s); + $dbh->query("INSERT INTO pearquote VALUES (1, $quoted)"); +} +$diff = array_diff($strings, $res = $dbh->getCol("SELECT s FROM pearquote")); +if (count($diff) > 0) { + echo "FAIL"; + print_r($strings); + print_r($res); +} else { + echo "OK"; +} + +$dbh->query("DELETE FROM pearquote"); + +echo "\nNumber escape test: "; +foreach ($nums as $n) { + $quoted = $dbh->quote($n); + $dbh->query("INSERT INTO pearquote VALUES ($quoted, 'foo')"); +} +$diff = array_diff($nums, $res = $dbh->getCol("SELECT n FROM pearquote")); +if (count($diff) > 0) { + echo "FAIL"; + print_r($nums); + print_r($res); +} else { + echo "OK\n"; +} +?> +--EXPECT-- +String escape test: OK +Number escape test: OK Index: pear/DB/tests/driver/connect.inc diff -u /dev/null pear/DB/tests/driver/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/connect.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,14 @@ +<?php +require './setup.inc'; +error_reporting(E_ALL); +require_once "DB.php"; +$dbh = DB::connect(DRIVER_DSN, array('optimize' => 'portability')); +if (DB::isError($dbh)) { + die("connect.inc: ".$dbh->toString()); +} + +function debug_die($o){ + die($o->toString()); +} + +?> Index: pear/DB/tests/driver/mktable.inc diff -u /dev/null pear/DB/tests/driver/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/mktable.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,15 @@ +<?php +require_once "./connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +//$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'debug_die'); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c VARCHAR(255), d VARCHAR(20))"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/driver/setup.inc diff -u /dev/null pear/DB/tests/driver/setup.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/setup.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,7 @@ +<?php +ini_set('include_path','.:'.PHP_LIBDIR); +define('DRIVER_DSN', ''); +//define('DRIVER_DSN', 'pgsql://postgres@localhost/test'); +//define('DRIVER_DSN', 'mysql://root@localhost/test'); +//define('DRIVER_DSN', 'oci8://system:manager@'); +?> \ No newline at end of file Index: pear/DB/tests/driver/skipif.inc diff -u /dev/null pear/DB/tests/driver/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/skipif.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,17 @@ +<?php +// This script prints "skip" unless: +// * the mysql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +include './setup.inc'; +require_once 'DB.php'; +if (!defined('DRIVER_DSN') || DRIVER_DSN == '') { + die("skip\n"); +} +$db = DB::connect(DRIVER_DSN); +if (DB::isError($db)) { + die("skip\n"); +} +?> \ No newline at end of file Index: pear/DB/tests/ibase/.cvsignore diff -u /dev/null pear/DB/tests/ibase/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/.cvsignore Sun May 12 03:29:25 2002 @@ -0,0 +1,5 @@ +*.exp +*.out +*.php +phpt.* +test.gdb Index: pear/DB/tests/ibase/01connect.phpt diff -u /dev/null pear/DB/tests/ibase/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/01connect.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_ibase::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/ibase/02fetch.phpt diff -u /dev/null pear/DB/tests/ibase/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/02fetch.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_ibase fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../fetchrow.inc"); +include(dirname(__FILE__)."/../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/ibase/03simplequery.phpt diff -u /dev/null pear/DB/tests/ibase/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/03simplequery.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_ibase::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/ibase/04numcols.phpt diff -u /dev/null pear/DB/tests/ibase/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/04numcols.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_ibase::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/ibase/06prepexec.phpt diff -u /dev/null pear/DB/tests/ibase/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/06prepexec.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_ibase::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/ibase/10errormap.phpt diff -u /dev/null pear/DB/tests/ibase/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/10errormap.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,26 @@ +--TEST-- +DB_ibase error mapping +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require dirname(__FILE__)."/../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 Index: pear/DB/tests/ibase/connect.inc diff -u /dev/null pear/DB/tests/ibase/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/connect.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,5 @@ +<?php +require_once "DB.php"; +$dbh = DB::connect("ibase://localhost/" . dirname(__FILE__). "/test.gdb?dialect=3", array('optimize'=>'portability')); +ibase_timefmt("%Y-%m-%d", IBASE_DATE); +?> Index: pear/DB/tests/ibase/mktable.inc diff -u /dev/null pear/DB/tests/ibase/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/mktable.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c VARCHAR(1024), d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/ibase/skipif.inc diff -u /dev/null pear/DB/tests/ibase/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/skipif.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,17 @@ +<?php +// This script prints "skip" unless: +// * the ibase extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +if (!extension_loaded("interbase") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("interbase$dlext"); +} +if (!extension_loaded("interbase")) { + die("skip\n"); +} +$conn = @ibase_connect("pear/DB/tests/ibase/test.gdb"); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/mysql/.cvsignore diff -u /dev/null pear/DB/tests/mysql/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/.cvsignore Sun May 12 03:29:25 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/mysql/01connect.phpt diff -u /dev/null pear/DB/tests/mysql/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/01connect.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_mysql::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/mysql/02fetch.phpt diff -u /dev/null pear/DB/tests/mysql/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/02fetch.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_mysql fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../fetchrow.inc"); +include(dirname(__FILE__)."/../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/mysql/03simplequery.phpt diff -u /dev/null pear/DB/tests/mysql/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/03simplequery.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_mysql::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/mysql/04numcols.phpt diff -u /dev/null pear/DB/tests/mysql/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/04numcols.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_mysql::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/mysql/05sequences.phpt diff -u /dev/null pear/DB/tests/mysql/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/05sequences.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,18 @@ +--TEST-- +DB_mysql sequences +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require dirname(__FILE__)."/../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +DB Error: no such table <- good error catched +a=1 +b=2 +b-a=1 +c=1 +d=1 +e=1 Index: pear/DB/tests/mysql/06prepexec.phpt diff -u /dev/null pear/DB/tests/mysql/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/06prepexec.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_mysql::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/mysql/07errornative.phpt diff -u /dev/null pear/DB/tests/mysql/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/07errornative.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,13 @@ +--TEST-- +DB_mysql::errorNative test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("syntax error please"); +print "error code " . $dbh->errorNative() . "\n"; +?> +--EXPECT-- +error code 1064 Index: pear/DB/tests/mysql/08affectedrows.phpt diff -u /dev/null pear/DB/tests/mysql/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/08affectedrows.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,33 @@ +--TEST-- +DB_mysql::affectedRows test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all (optimize=%s)\n", $dbh->affectedRows(), + $dbh->getOption("optimize")); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->setOption("optimize", "portability"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all (optimize=%s)\n", $dbh->affectedRows(), + $dbh->getOption("optimize")); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +0 after delete all (optimize=performance) +2 after delete all (optimize=portability) Index: pear/DB/tests/mysql/09numrows.phpt diff -u /dev/null pear/DB/tests/mysql/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/09numrows.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_mysql::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require dirname(__FILE__)."/../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 Index: pear/DB/tests/mysql/10errormap.phpt diff -u /dev/null pear/DB/tests/mysql/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/10errormap.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,24 @@ +--TEST-- +DB_mysql error mapping +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require dirname(__FILE__)."/../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: pear/DB/tests/mysql/12tableinfo.phpt diff -u /dev/null pear/DB/tests/mysql/12tableinfo.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/12tableinfo.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,127 @@ +--TEST-- +DB_mysql tableInfo test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../tableinfo.inc"); +?> +--EXPECT-- +testing tableInfo: + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +eight (last) field: +table => phptest_fk +name => d +type => date +len => 10 +flags => + +testing tableInfo (DB_TABLEINFO_ORDER): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +eight field: +table => phptest +name => d +type => date +len => 10 +flags => + +num_fields: +8 + +order: +a => 4 +b => 1 +c => 6 +d => 7 +fk => 5 + +testing tableInfo (DB_TABLEINFO_ORDERTABLE): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +eight field: +table => phptest +name => d +type => date +len => 10 +flags => + +num_fields: +8 + +ordertable: +phptest => Array +phptest_fk => Array + +ordertable[phptest]: +a => 0 +b => 1 +c => 2 +d => 3 + +ordertable[phptest_fk]: +a => 4 +fk => 5 +c => 6 +d => 7 + +testing tableInfo (table without query-result): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +fourth (last) field: +table => phptest +name => d +type => date +len => 10 +flags => + +testing tableInfo (table without query-result and DB_TABLEINFO_FULL): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +order: +a => 0 +b => 1 +c => 2 +d => 3 + +ordertable: +phptest => Array + +ordertable[phptest]: +a => 0 +b => 1 +c => 2 +d => 3 Index: pear/DB/tests/mysql/13limit.phpt diff -u /dev/null pear/DB/tests/mysql/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/13limit.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_mysql row limit +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include dirname(__FILE__).'/../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/mysql/14fetchmode_object.phpt diff -u /dev/null pear/DB/tests/mysql/14fetchmode_object.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/14fetchmode_object.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_mysql::fetchmode object +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include dirname(__FILE__).'/../fetchmode_object.inc'; +?> +--EXPECT-- +--- fetch with param DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row --- +db_row -> a b c d +db_row -> a b c d Index: pear/DB/tests/mysql/connect.inc diff -u /dev/null pear/DB/tests/mysql/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/connect.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,7 @@ +<?php +require_once "DB.php"; +$dbh = DB::connect("mysql://localhost/test"); +if (DB::isError($dbh)) { + die("connect.inc: ".$dbh->getMessage()); +} +?> Index: pear/DB/tests/mysql/mktable.inc diff -u /dev/null pear/DB/tests/mysql/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/mktable.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/mysql/skipif.inc diff -u /dev/null pear/DB/tests/mysql/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/skipif.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,22 @@ +<?php +// This script prints "skip" unless: +// * the mysql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("mysql") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("mysql$dlext"); +} +if (!extension_loaded("mysql")) { + die("skip\n"); +} +$conn = @mysql_connect("localhost"); +if (!is_resource($conn)) { + die("skip\n"); +} +if (!mysql_select_db("test", $conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/oci8/.cvsignore diff -u /dev/null pear/DB/tests/oci8/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/.cvsignore Sun May 12 03:29:26 2002 @@ -0,0 +1,5 @@ +*.exp +*.out +*.php +phpt.* +sqlnet.log Index: pear/DB/tests/oci8/01connect.phpt diff -u /dev/null pear/DB/tests/oci8/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/01connect.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_oci8::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/oci8/02fetch.phpt diff -u /dev/null pear/DB/tests/oci8/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/02fetch.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,37 @@ +--TEST-- +DB_oci8::fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +A B C D +testing fetchmodes: fetchrow ordered default with assoc specified +A B C D +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +A B C D +testing fetchmodes: fetchinto ordered default with assoc specified +A B C D +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/oci8/03simplequery.phpt diff -u /dev/null pear/DB/tests/oci8/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/03simplequery.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,11 @@ +--TEST-- +DB_oci8::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/oci8/04numcols.phpt diff -u /dev/null pear/DB/tests/oci8/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/04numcols.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,14 @@ +--TEST-- +DB_oci8::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/oci8/05sequences.phpt diff -u /dev/null pear/DB/tests/oci8/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/05sequences.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,18 @@ +--TEST-- +DB_oci8::sequences +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require dirname(__FILE__)."/../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +DB Error: no such table <- good error catched +a=1 +b=2 +b-a=1 +c=1 +d=1 +e=1 Index: pear/DB/tests/oci8/06prepexec.phpt diff -u /dev/null pear/DB/tests/oci8/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/06prepexec.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,20 @@ +--TEST-- +DB_oci8::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/oci8/07errornative.phpt diff -u /dev/null pear/DB/tests/oci8/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/07errornative.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,11 @@ +--TEST-- +DB_oci8::errorNative test +--SKIPIF-- +<?php /*include("skipif.inc");*/ print "skip\n"; ?> +--FILE-- +<?php +include("mktable.inc"); +$err = $dbh->query("SELECT foo FROM tablethatdoesnotexist"); +print $dbh->errorNative() . "\n"; +?> +--EXPECT-- Index: pear/DB/tests/oci8/08affectedrows.phpt diff -u /dev/null pear/DB/tests/oci8/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/08affectedrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,24 @@ +--TEST-- +DB_oci8::affectedRows test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all\n", $dbh->affectedRows()); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +3 after delete all Index: pear/DB/tests/oci8/09numrows.phpt diff -u /dev/null pear/DB/tests/oci8/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/09numrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,34 @@ +--TEST-- +DB_oci8::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +$dbh->autoCommit(false); +$dbh->setOption("optimize", "portability"); +$test_error_mode = PEAR_ERROR_PRINT; +include "../numrows.inc"; +$dbh->rollback(); +$dbh->setOption("optimize", "performance"); +include "../numrows.inc"; +$dbh->rollback(); +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable Index: pear/DB/tests/oci8/10errormap.phpt diff -u /dev/null pear/DB/tests/oci8/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/10errormap.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,27 @@ +--TEST-- +DB_oci8::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 + DB Error: constraint violation +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 Index: pear/DB/tests/oci8/13limit.phpt diff -u /dev/null pear/DB/tests/oci8/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/13limit.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_oci8::row limit +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include '../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/oci8/connect.inc diff -u /dev/null pear/DB/tests/oci8/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/connect.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,9 @@ +<?php +$path = dirname(__FILE__) . "/../../.."; +ini_set('include_path', realpath($path)); +require_once "DB.php"; +$dbh = DB::connect("oci8://system:manager@test", array('debug' => 2)); +if (PEAR::isError($dbh)) { + die($dbh->tostring()); +} +?> Index: pear/DB/tests/oci8/mktable.inc diff -u /dev/null pear/DB/tests/oci8/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/mktable.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,20 @@ +<?php + +require_once dirname(__FILE__)."/connect.inc"; + +function mktable_error_handler($errobj) { + print "mktable error: ".$errobj->getMessage().": ".$errobj->getUserInfo(); + print "\n"; + exit; +} +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "mktable_error_handler"); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR2(40), c LONG VARCHAR, d VARCHAR2(20))"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/oci8/skipif.inc diff -u /dev/null pear/DB/tests/oci8/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/skipif.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,17 @@ +<?php +// This script prints "skip" unless: +// * the ibase extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +if (!extension_loaded("oci8") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("oci8$dlext"); +} +if (!extension_loaded("oci8")) { + die("skip\n"); +} +$conn = @OCILogon("system", "manager", "test"); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/odbc/.cvsignore diff -u /dev/null pear/DB/tests/odbc/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/.cvsignore Sun May 12 03:29:26 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/odbc/01connect.phpt diff -u /dev/null pear/DB/tests/odbc/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/01connect.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,18 @@ +--TEST-- +ODBC DB::connect +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/odbc/02fetch.phpt diff -u /dev/null pear/DB/tests/odbc/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/02fetch.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_odbc fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/odbc/03simplequery.phpt diff -u /dev/null pear/DB/tests/odbc/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/03simplequery.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_odbc::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/odbc/04numcols.phpt diff -u /dev/null pear/DB/tests/odbc/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/04numcols.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_odbc::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/odbc/06prepexec.phpt diff -u /dev/null pear/DB/tests/odbc/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/06prepexec.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_odbc::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/odbc/07errornative.phpt diff -u /dev/null pear/DB/tests/odbc/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/07errornative.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,13 @@ +--TEST-- +DB_odbc::errorNative test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("syntax error please"); +print "error code " . $dbh->errorNative() . "\n"; +?> +--EXPECT-- +error code 1064 Index: pear/DB/tests/odbc/09numrows.phpt diff -u /dev/null pear/DB/tests/odbc/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/09numrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,20 @@ +--TEST-- +DB_odbc::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 +DB Error: unknown error Index: pear/DB/tests/odbc/10errormap.phpt diff -u /dev/null pear/DB/tests/odbc/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/10errormap.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,24 @@ +--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: pear/DB/tests/odbc/connect.inc diff -u /dev/null pear/DB/tests/odbc/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/connect.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,11 @@ +<?php +require_once "DB.php"; +require "dsn.inc"; +if (!$dsn) { + die("tests not configure for this environment"); +} +$dbh = DB::connect($dsn); +if (DB::isError($dbh)) { + die("connect.inc: ".$dbh->getMessage()); +} +?> Index: pear/DB/tests/odbc/dsn.inc diff -u /dev/null pear/DB/tests/odbc/dsn.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/dsn.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +<?php + +switch (ODBC_TYPE) { + case "solid": + $nativedsn = "tcp localhost 1313"; + $dsn = "odbc://tcp+localhost+1313"; + $user = $pass = "test"; + break; + case "iodbc": + $nativedsn = "test"; + $dsn = "odbc://test"; + $user = $pass = ""; + break; + default: + $nativedsn = $dsn = $user = $pass = ""; + break; +} + +?> Index: pear/DB/tests/odbc/mktable.inc diff -u /dev/null pear/DB/tests/odbc/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/mktable.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/odbc/skipif.inc diff -u /dev/null pear/DB/tests/odbc/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/skipif.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,23 @@ +<?php +// This script prints "skip" unless: +// * the odbc extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("odbc") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("odbc$dlext"); +} +if (!extension_loaded("odbc")) { + die("skip\n"); +} +require "dsn.inc"; +if (!$nativedsn) { + die("skip\n"); +} +$conn = @odbc_connect($nativedsn, $user, $pass); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/pgsql/.cvsignore diff -u /dev/null pear/DB/tests/pgsql/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/.cvsignore Sun May 12 03:29:26 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/pgsql/01connect.phpt diff -u /dev/null pear/DB/tests/pgsql/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/01connect.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_pgsql::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/pgsql/02fetch.phpt diff -u /dev/null pear/DB/tests/pgsql/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/02fetch.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_pgsql fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 11-21-1999 +row 2: 1, one, One, 02-16-2001 +row 3: 2, two, Two, 02-15-2001 +row 4: 3, three, Three, 02-14-2001 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/pgsql/03simplequery.phpt diff -u /dev/null pear/DB/tests/pgsql/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/03simplequery.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_pgsql::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/pgsql/04numcols.phpt diff -u /dev/null pear/DB/tests/pgsql/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/04numcols.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_pgsql::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/pgsql/05sequences.phpt diff -u /dev/null pear/DB/tests/pgsql/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/05sequences.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,16 @@ +--TEST-- +DB_pgsql sequences +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +a=1 +b=2 +b-a=1 +c=1 +d=1 Index: pear/DB/tests/pgsql/06prepexec.phpt diff -u /dev/null pear/DB/tests/pgsql/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/06prepexec.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_pgsql::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/pgsql/07errornative.phpt diff -u /dev/null pear/DB/tests/pgsql/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/07errornative.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,13 @@ +--TEST-- +DB_pgsql::errorNative test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("syntax error please"); +print $dbh->errorNative() . "\n"; +?> +--EXPECT-- +ERROR: parser: parse error at or near "syntax" Index: pear/DB/tests/pgsql/08affectedrows.phpt diff -u /dev/null pear/DB/tests/pgsql/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/08affectedrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,25 @@ +--TEST-- +DB_pgsql::affectedRows test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all\n", $dbh->affectedRows()); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +3 after delete all Index: pear/DB/tests/pgsql/09numrows.phpt diff -u /dev/null pear/DB/tests/pgsql/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/09numrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_pgsql::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 Index: pear/DB/tests/pgsql/10errormap.phpt diff -u /dev/null pear/DB/tests/pgsql/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/10errormap.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,28 @@ +--TEST-- +DB_pgsql error mapping +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +// The DB_ERROR_CONSTRAINT test will fail on PostgreSQL < 7.x +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 + DB Error: constraint violation +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 Index: pear/DB/tests/pgsql/11transact.phpt diff -u /dev/null pear/DB/tests/pgsql/11transact.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/11transact.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_pgsql transaction test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../transactions.inc"; +?> +--EXPECT-- +after autocommit: bing one ops=0 +before commit: bing one two three ops=2 +after commit: bing one two three ops=0 +before rollback: bing one two three four five ops=2 +after rollback: bing one two three ops=0 +before autocommit+rollback: bing one two three six seven ops=0 +after autocommit+rollback: bing one two three six seven ops=0 +testing that select doesn't disturbe opcount: ok Index: pear/DB/tests/pgsql/13limit.phpt diff -u /dev/null pear/DB/tests/pgsql/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/13limit.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_pgsql row limit +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include '../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/pgsql/14fetchmode_object.phpt diff -u /dev/null pear/DB/tests/pgsql/14fetchmode_object.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/14fetchmode_object.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_pgsql::fetchmode object +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require './connect.inc'; +include '../fetchmode_object.inc'; +?> +--EXPECT-- +--- fetch with param DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row --- +db_row -> a b c d +db_row -> a b c d Index: pear/DB/tests/pgsql/connect.inc diff -u /dev/null pear/DB/tests/pgsql/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/connect.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,4 @@ +<?php +require_once "DB.php"; +$dbh = DB::connect("pgsql://unix+localhost/test"); +?> Index: pear/DB/tests/pgsql/mktable.inc diff -u /dev/null pear/DB/tests/pgsql/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/mktable.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/pgsql/skipif.inc diff -u /dev/null pear/DB/tests/pgsql/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/skipif.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +<?php +// This script prints "skip" unless: +// * the pgsql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("pgsql") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("pgsql$dlext"); +} +if (!extension_loaded("pgsql")) { + die("skip\n"); +} +$conn = @pg_connect("host=localhost dbname=test"); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/ibase/05sequences.phpt +++ pear/DB/tests/ibase/05sequences.phpt --TEST-- DB_driver::sequences --SKIPIF-- <?php require "skipif.inc"; ?> --FILE-- <?php /* Test output differs from the standard DB sequences test due to a bug in the php interbase driver, that returns numbers as strings; */ require "connect.inc"; require dirname(__FILE__)."/../sequences.inc"; ?> --EXPECT-- DB Error: unknown error a=1. b=2. b-a=1 c=1. d=1. Index: pear/DB/tests/oci8/12tableinfo.phpt +++ pear/DB/tests/oci8/12tableinfo.phpt --TEST-- DB_oci8::tableInfo test --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include dirname(__FILE__)."/mktable.inc"; print "Printing output for dbh->tableInfo('phptest')\n"; print_r($dbh->tableInfo('phptest')); print "Printing output for res->tableInfo()\n"; $res = $dbh->query('SELECT * FROM phptest'); print_r($res->tableInfo()); ?> --EXPECT-- Printing output for dbh->tableInfo('phptest') Array ( [0] => Array ( [table] => PHPTEST [name] => A [type] => NUMBER [len] => 22 [format] => [nullable] => 1 [default] => ) [1] => Array ( [table] => PHPTEST [name] => B [type] => VARCHAR2 [len] => 40 [format] => [nullable] => 1 [default] => ) [2] => Array ( [table] => PHPTEST [name] => C [type] => LONG [len] => 0 [format] => [nullable] => 1 [default] => ) [3] => Array ( [table] => PHPTEST [name] => D [type] => VARCHAR2 [len] => 20 [format] => [nullable] => 1 [default] => ) [num_fields] => 4 ) Printing output for res->tableInfo() Array ( [0] => Array ( [name] => A [type] => NUMBER [len] => 22 [table] => A [format] => [nullable] => [default] => ) [1] => Array ( [name] => B [type] => VARCHAR [len] => 40 [table] => B [format] => [nullable] => 1 [default] => ) [2] => Array ( [name] => C [type] => LONG [len] => 2147483647 [table] => PHPTEST [format] => [nullable] => 1 [default] => ) [3] => Array ( [name] => D [type] => VARCHAR [len] => 20 [table] => PHPTEST [format] => [nullable] => 1 [default] => ) [num_fields] => 4 )
Index: pear/DB/tests/.cvsignore diff -u /dev/null pear/DB/tests/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/.cvsignore Sun May 12 03:29:24 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/db_error.phpt diff -u /dev/null pear/DB/tests/db_error.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_error.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,78 @@ +--TEST-- +DB_Error/DB_Warning test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB.php +// Parts tested: DB_Error, DB_Warning + +function test_error_handler($errno, $errmsg, $file, $line, $vars) { + $errortype = array ( + 1 => "Error", + 2 => "Warning", + 4 => "Parsing Error", + 8 => "Notice", + 16 => "Core Error", + 32 => "Core Warning", + 64 => "Compile Error", + 128 => "Compile Warning", + 256 => "User Error", + 512 => "User Warning", + 1024=> "User Notice" + ); + $prefix = $errortype[$errno]; + $file = basename($file); + print "\n$prefix: $errmsg in $file on line $line\n"; +} + +error_reporting(E_ALL); +set_error_handler("test_error_handler"); +require_once "DB.php"; + +print "testing different error codes...\n"; +$e = new DB_Error(); print $e->toString()."\n"; +$e = new DB_Error("test error"); print $e->toString()."\n"; +$e = new DB_Error(DB_OK); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR_SYNTAX); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR_DIVZERO); print $e->toString()."\n"; +$e = new DB_Warning(); print $e->toString()."\n"; +$e = new DB_Warning("test warning"); print $e->toString()."\n"; +$e = new DB_Warning(DB_WARNING_READ_ONLY); print $e->toString()."\n"; + +print "testing different error modes...\n"; +$e = new DB_Error(DB_ERROR, PEAR_ERROR_PRINT); print $e->toString()."\n"; +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER); + +print "testing different error serverities...\n"; +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER, E_USER_NOTICE); +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER, E_USER_WARNING); +$e = new DB_Error(DB_ERROR_SYNTAX, PEAR_ERROR_TRIGGER, E_USER_ERROR); + +?> +--GET-- +--POST-- +--EXPECT-- +testing different error codes... +[db_error: message="DB Error: unknown error" code=-1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: test error" code=-1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: no error" code=1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: unknown error" code=-1 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: syntax error" code=-2 mode=return level=notice prefix="" info=""] +[db_error: message="DB Error: division by zero" code=-13 mode=return level=notice prefix="" info=""] +[db_warning: message="DB Warning: unknown warning" code=-1000 mode=return level=notice prefix="" info=""] +[db_warning: message="DB Warning: test warning" code=0 mode=return level=notice prefix="" info=""] +[db_warning: message="DB Warning: read only" code=-1001 mode=return level=notice prefix="" info=""] +testing different error modes... +DB Error: unknown error[db_error: message="DB Error: unknown error" code=-1 mode=print level=notice prefix="" info=""] + +User Notice: DB Error: syntax error in PEAR.php on line 591 +testing different error serverities... + +User Notice: DB Error: syntax error in PEAR.php on line 591 + +User Warning: DB Error: syntax error in PEAR.php on line 591 + +User Error: DB Error: syntax error in PEAR.php on line 591 Index: pear/DB/tests/db_error2.phpt diff -u /dev/null pear/DB/tests/db_error2.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_error2.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,76 @@ +--TEST-- +DB configurable error handler test +--FILE-- +<?php + +require_once "DB.php"; +error_reporting(4095); + +function myfunc(&$obj) { + print "myfunc here, obj=".$obj->toString()."\n"; +} +function myfunc2(&$obj) { + print "myfunc2 here, obj=".$obj->toString()."\n"; +} +class myclass { + function myfunc(&$obj) { + print "myclass::myfunc here, obj=".$obj->toString()."\n"; + } +} +function test_error_handler($errno, $errmsg, $file, $line, $vars) { + $errortype = array ( + 1 => "Error", + 2 => "Warning", + 4 => "Parsing Error", + 8 => "Notice", + 16 => "Core Error", + 32 => "Core Warning", + 64 => "Compile Error", + 128 => "Compile Warning", + 256 => "User Error", + 512 => "User Warning", + 1024=> "User Notice" + ); + $prefix = $errortype[$errno]; + $file = basename($file); + print "$prefix: $errmsg in $file on line $line\n"; +} + +$obj = new myclass; + +$dbh = DB::factory("mysql"); + +print "default: "; +$e = $dbh->raiseError("return testing error"); +print $e->toString() . "\n"; + +print "global default: "; +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "myfunc2"); +$e = $dbh->raiseError("global default test"); + +$dbh->setErrorHandling(PEAR_ERROR_PRINT); +print "mode=print: "; +$e = $dbh->raiseError("print testing error"); +print "\n"; + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "myfunc"); +print "mode=function callback: "; +$e = $dbh->raiseError("function callback testing error"); + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($obj, "myfunc")); +print "mode=object callback: "; +$e = $dbh->raiseError("object callback testing error"); + +set_error_handler("test_error_handler"); +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +print "mode=trigger: "; +$e = $dbh->raiseError("trigger testing error"); + +?> +--EXPECT-- +default: [db_error: message="DB Error: return testing error" code=-1 mode=return level=notice prefix="" info=""] +global default: myfunc2 here, obj=[db_error: message="DB Error: global default test" code=-1 mode=callback callback=myfunc2 prefix="" info=""] +mode=print: DB Error: print testing error +mode=function callback: myfunc here, obj=[db_error: message="DB Error: function callback testing error" code=-1 mode=callback callback=myfunc prefix="" info=""] +mode=object callback: myclass::myfunc here, obj=[db_error: message="DB Error: object callback testing error" code=-1 mode=callback callback=myclass::myfunc prefix="" info=""] +mode=trigger: User Notice: DB Error: trigger testing error in PEAR.php on line 591 Index: pear/DB/tests/db_factory.phpt diff -u /dev/null pear/DB/tests/db_factory.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_factory.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,46 @@ +--TEST-- +DB::factory test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB.php +// Parts tested: DB_Error, DB_Warning + +require_once "DB.php"; + +$backends = array( + "ibase", + "msql", + "mssql", + "mysql", + "oci8", + "odbc", + "pgsql", + "sybase" +); + +reset($backends); +while (list($i, $name) = each($backends)) { + print "testing $name: "; + $obj = DB::factory($name); + if (DB::isError($obj)) { + print "error: ".$obj->getMessage()."\n"; + } else { + print "object: ".$obj->toString()."\n"; + } +} + +?> +--GET-- +--POST-- +--EXPECT-- +testing ibase: object: db_ibase: (phptype=ibase, dbsyntax=ibase) +testing msql: object: db_msql: (phptype=msql, dbsyntax=msql) +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=sql92) +testing pgsql: object: db_pgsql: (phptype=pgsql, dbsyntax=pgsql) +testing sybase: object: db_sybase: (phptype=sybase, dbsyntax=sybase) Index: pear/DB/tests/db_ismanip.phpt diff -u /dev/null pear/DB/tests/db_ismanip.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_ismanip.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,60 @@ +--TEST-- +DB::isManip test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB.php +// Parts tested: DB::isManip + +require_once "DB.php"; + +function test($query) { + printf("%s : %d\n", preg_replace('/\s+.*/', '', $query), + DB::isManip($query)); +} + +print "testing DB::isManip...\n"; + +test("SELECT * FROM table"); +test("Select * from table"); +test("select * From table"); +test("sElECt * frOm table"); +test("SELECT DISTINCT name FROM table"); +test("UPDATE table SET foo = 'bar'"); +test("DELETE FROM table"); +test("delete from table where id is null"); +test("create table (id integer, name varchar(100))"); +test("CREATE SEQUENCE foo"); +test("\"CREATE PROCEDURE foo\""); +test("GRANT SELECT ON table TO user"); +test("REVOKE SELECT ON table FROM user"); +test("SHOW OPTIONS"); +test("DROP TABLE foo"); +test("ALTER TABLE foo ADD COLUMN (bar INTEGER)"); +test(" SELECT * FROM table"); +test(" DELETE FROM table"); +?> +--GET-- +--POST-- +--EXPECT-- +testing DB::isManip... +SELECT : 0 +Select : 0 +select : 0 +sElECt : 0 +SELECT : 0 +UPDATE : 1 +DELETE : 1 +delete : 1 +create : 1 +CREATE : 1 +"CREATE : 1 +GRANT : 1 +REVOKE : 1 +SHOW : 0 +DROP : 1 +ALTER : 1 + : 0 + : 1 Index: pear/DB/tests/db_parsedsn.phpt diff -u /dev/null pear/DB/tests/db_parsedsn.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/db_parsedsn.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,311 @@ +--TEST-- +DB::parseDSN test +--SKIPIF-- +<?php if (!@include("DB.php")) print "skip"; ?> +--FILE-- +<?php // -*- C++ -*- + +// Test for: DB::parseDSN() + +include_once dirname(__FILE__)."/../../DB.php"; + +function test($dsn) { + echo "DSN: $dsn\n"; + print_r(DB::parseDSN($dsn)); +} + +print "testing DB::parseDSN...\n\n"; + +test("mysql"); +test("odbc(mssql)"); +test("mysql://localhost"); +test("mysql://remote.host.com/db"); +test("oci8://system:manager@"); +test("oci8://user:pass@tns-name"); +test("odbc(solid)://foo:bar@tcp+localhost+1313"); // deprecated +test("pgsql://user@unix+localhost/pear"); // deprecated +test("ibase://user%40domain:password@host"); +test("ibase://user@domain:pass@word@/database"); // also supported +test("ifx://user@domain:pass@word@host.com//usr/db/general.db"); +test('ifx://remote.host.com/c:\windows\my.db'); + +// new formats +test("odbc(solid)://foo:bar@localhost:1313"); +test("pgsql://user@unix()/pear"); +test("mysql://user@unix(/path/to/socket)/pear"); +test("pgsql://user@tcp()/pear"); +test("pgsql://user@tcp(somehost)/pear"); +test("pgsql://user:pass@word@tcp(somehost:7777)/pear"); + +// special backend options +test('ibase://user:pass@localhost//var/lib/dbase.dbf?role=foo'); +test('dbase://@/?role=foo&dialect=bar'); +?> +--GET-- +--POST-- +--EXPECT-- +testing DB::parseDSN... + +DSN: mysql +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => + [password] => + [protocol] => + [hostspec] => + [port] => + [socket] => + [database] => +) +DSN: odbc(mssql) +Array +( + [phptype] => odbc + [dbsyntax] => mssql + [username] => + [password] => + [protocol] => + [hostspec] => + [port] => + [socket] => + [database] => +) +DSN: mysql://localhost +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => + [password] => + [protocol] => tcp + [hostspec] => localhost + [port] => + [socket] => + [database] => +) +DSN: mysql://remote.host.com/db +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => + [password] => + [protocol] => tcp + [hostspec] => remote.host.com + [port] => + [socket] => + [database] => db +) +DSN: oci8://system:manager@ +Array +( + [phptype] => oci8 + [dbsyntax] => oci8 + [username] => system + [password] => manager + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => +) +DSN: oci8://user:pass@tns-name +Array +( + [phptype] => oci8 + [dbsyntax] => oci8 + [username] => user + [password] => pass + [protocol] => tcp + [hostspec] => tns-name + [port] => + [socket] => + [database] => +) +DSN: odbc(solid)://foo:bar@tcp+localhost+1313 +Array +( + [phptype] => odbc + [dbsyntax] => solid + [username] => foo + [password] => bar + [protocol] => tcp + [hostspec] => localhost 1313 + [port] => + [socket] => + [database] => +) +DSN: pgsql://user@unix+localhost/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => unix + [hostspec] => + [port] => + [socket] => localhost + [database] => pear +) +DSN: ibase://user%40domain:password@host +Array +( + [phptype] => ibase + [dbsyntax] => ibase + [username] => user@domain + [password] => password + [protocol] => tcp + [hostspec] => host + [port] => + [socket] => + [database] => +) +DSN: ibase://user@domain:pass@word@/database +Array +( + [phptype] => ibase + [dbsyntax] => ibase + [username] => user@domain + [password] => pass@word + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => database +) +DSN: ifx://user@domain:pass@word@host.com//usr/db/general.db +Array +( + [phptype] => ifx + [dbsyntax] => ifx + [username] => user@domain + [password] => pass@word + [protocol] => tcp + [hostspec] => host.com + [port] => + [socket] => + [database] => /usr/db/general.db +) +DSN: ifx://remote.host.com/c:\windows\my.db +Array +( + [phptype] => ifx + [dbsyntax] => ifx + [username] => + [password] => + [protocol] => tcp + [hostspec] => remote.host.com + [port] => + [socket] => + [database] => c:\windows\my.db +) +DSN: odbc(solid)://foo:bar@localhost:1313 +Array +( + [phptype] => odbc + [dbsyntax] => solid + [username] => foo + [password] => bar + [protocol] => tcp + [hostspec] => localhost + [port] => 1313 + [socket] => + [database] => +) +DSN: pgsql://user@unix()/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => unix + [hostspec] => + [port] => + [socket] => + [database] => pear +) +DSN: mysql://user@unix(/path/to/socket)/pear +Array +( + [phptype] => mysql + [dbsyntax] => mysql + [username] => user + [password] => + [protocol] => unix + [hostspec] => + [port] => + [socket] => /path/to/socket + [database] => pear +) +DSN: pgsql://user@tcp()/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => pear +) +DSN: pgsql://user@tcp(somehost)/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => + [protocol] => tcp + [hostspec] => somehost + [port] => + [socket] => + [database] => pear +) +DSN: pgsql://user:pass@word@tcp(somehost:7777)/pear +Array +( + [phptype] => pgsql + [dbsyntax] => pgsql + [username] => user + [password] => pass@word + [protocol] => tcp + [hostspec] => somehost + [port] => 7777 + [socket] => + [database] => pear +) +DSN: ibase://user:pass@localhost//var/lib/dbase.dbf?role=foo +Array +( + [phptype] => ibase + [dbsyntax] => ibase + [username] => user + [password] => pass + [protocol] => tcp + [hostspec] => localhost + [port] => + [socket] => + [database] => /var/lib/dbase.dbf + [role] => foo +) +DSN: dbase://@/?role=foo&dialect=bar +Array +( + [phptype] => dbase + [dbsyntax] => dbase + [username] => + [password] => + [protocol] => tcp + [hostspec] => + [port] => + [socket] => + [database] => + [role] => foo + [dialect] => bar +) Index: pear/DB/tests/errors.inc diff -u /dev/null pear/DB/tests/errors.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/errors.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,49 @@ +<?php + +function errhandler($obj) +{ + if ($obj->getCode() == DB_ERROR) { + print " unknown: ".$obj->getUserInfo()."\n"; + } else { + $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($test_mktable_query); + +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 b"); +$dbh->query("DROP TABLE a"); +$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)"); + +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: pear/DB/tests/fetchmode_object.inc diff -u /dev/null pear/DB/tests/fetchmode_object.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/fetchmode_object.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,42 @@ +<?php +error_reporting(E_ALL); +function pe($obj) { + die($obj->getMessage() . "\n" . $obj->getDebugInfo()); +} + +function print_obj(&$obj) { + if (!is_object($obj)) { + echo "ERROR: no object!\n"; + } else { + echo get_class($obj) . " -> " . implode(" ", array_keys((array)$obj)) . "\n"; + } +} + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe'); + +echo "--- fetch with param DB_FETCHMODE_OBJECT ---\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(DB_FETCHMODE_OBJECT); +print_obj($row); +$sth = $dbh->query("SELECT * FROM phptest"); +$sth->fetchInto($row, DB_FETCHMODE_OBJECT); +print_obj($row); + +echo "--- fetch with default fetchmode DB_FETCHMODE_OBJECT ---\n"; +$dbh->setFetchMode(DB_FETCHMODE_OBJECT); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print_obj($row); +$sth = $dbh->query("SELECT * FROM phptest"); +$sth->fetchInto($row); +print_obj($row); + +echo "--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row ---\n"; +$dbh->setFetchMode(DB_FETCHMODE_OBJECT, 'DB_Row'); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print_obj($row); +$sth = $dbh->query("SELECT * FROM phptest"); +$sth->fetchInto($row); +print_obj($row); +?> \ No newline at end of file Index: pear/DB/tests/fetchmodes.inc diff -u /dev/null pear/DB/tests/fetchmodes.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/fetchmodes.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,68 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); + +print "testing fetchmodes: fetchrow default default\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto default default\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow ordered default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow assoc default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow ordered default with assoc specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(DB_FETCHMODE_ASSOC); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchrow assoc default with ordered specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = $sth->fetchRow(DB_FETCHMODE_ORDERED); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto ordered default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto assoc default\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto ordered default with assoc specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ORDERED); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row, DB_FETCHMODE_ASSOC); +print implode(" ", array_keys($row))."\n"; + +print "testing fetchmodes: fetchinto assoc default with ordered specified\n"; +$dbh->setFetchMode(DB_FETCHMODE_ASSOC); +$sth = $dbh->query("SELECT * FROM phptest"); +$row = array(); +$sth->fetchInto($row, DB_FETCHMODE_ORDERED); +print implode(" ", array_keys($row))."\n"; + +?> Index: pear/DB/tests/fetchrow.inc diff -u /dev/null pear/DB/tests/fetchrow.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/fetchrow.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,26 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$dbh->query("INSERT INTO phptest VALUES(1, 'one', 'One', '2001-02-16')"); +$dbh->query("INSERT INTO phptest VALUES(2, 'two', 'Two', '2001-02-15')"); +$dbh->query("INSERT INTO phptest VALUES(3, 'three', 'Three', '2001-02-14')"); + +print "testing fetchrow:\n"; +$sth = $dbh->query("SELECT * FROM phptest"); +for ($i = 1; $i <= 5; $i++) { + print "row $i: "; + $row = $sth->fetchRow(); + if (DB::isError($row)) { + print $row->toString() . "\n"; + continue; + } + if (is_array($row)) { + print implode(", ", $row) . "\n"; + } else { + var_dump($row); + } +} + +$dbh->query("DELETE FROM phptest WHERE a <> 42"); + +?> Index: pear/DB/tests/limit.inc diff -u /dev/null pear/DB/tests/limit.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/limit.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,33 @@ +<?php +error_reporting(E_ALL); +function pe($obj) { + die($obj->getMessage() . "\n" . $obj->getDebugInfo()); +} +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE php_limit"); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe'); +$dbh->query("CREATE TABLE php_limit (a VARCHAR(20))"); +$from = 0; +$count = 10; +$numrows = 30; + +for ($i=0; $i<=$numrows+2; $i++) { + $dbh->query("INSERT INTO php_limit VALUES('result $i')"); +} +// Hack for upper case col returned by Oracle +if ($dbh->dsn['phptype'] == 'oci8' && + $dbh->options['optimize'] != 'portability') { + $key = 'A'; +} else { + $key = 'a'; +} +for ($i = 0; $i <= 3; $i++) { + $from = 10 * $i; + $res = $dbh->limitQuery("select * from php_limit", $from, $count); + echo "======= From: $from || Number of rows to fetch: $count =======\n"; + while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { + echo $res->getRowCounter() . '.- ' . $row[$key] . "\n"; + } +} +//$dbh->query("DROP TABLE php_limit"); +?> \ No newline at end of file Index: pear/DB/tests/numcols.inc diff -u /dev/null pear/DB/tests/numcols.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/numcols.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,13 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$sth = $dbh->query("SELECT a FROM phptest"); +printf("%d\n", $sth->numCols()); +$sth = $dbh->query("SELECT a,b FROM phptest"); +printf("%d\n", $sth->numCols()); +$sth = $dbh->query("SELECT a,b,c FROM phptest"); +printf("%d\n", $sth->numCols()); +$sth = $dbh->query("SELECT * FROM phptest"); +printf("%d\n", $sth->numCols()); + +?> Index: pear/DB/tests/numrows.inc diff -u /dev/null pear/DB/tests/numrows.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/numrows.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,44 @@ +<?php + +if (!function_exists("errhandler")) +{ + function errhandler($obj) + { + printf("%s\n", $obj->getMessage()); + } +} + +if (isset($test_error_mode)) { + $dbh->setErrorHandling($test_error_mode); +} else { + $dbh->setErrorHandling(PEAR_ERROR_DIE); +} +$sth = $dbh->query("SELECT a FROM phptest"); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; +} else { + print "\n"; +} +for ($i = 0; $i < 5; $i++) { + $sth = $dbh->query("INSERT INTO phptest (a) VALUES($i)"); + $sth = $dbh->query("SELECT a FROM phptest"); + if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; + } else { + print "\n"; + } +} +$dbh->query("DELETE FROM phptest WHERE a < 4"); +$sth = $dbh->query("SELECT a FROM phptest"); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; +} else { + print "\n"; +} +$sth = $dbh->query("SELECT a FROM phptest where a < 0"); +if (!DB::isError($rows = $sth->numRows())) { + print "$rows\n"; +} else { + print "\n"; +} +?> Index: pear/DB/tests/prepexe.inc diff -u /dev/null pear/DB/tests/prepexe.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/prepexe.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,33 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$sth1 = $dbh->prepare("INSERT INTO phptest (a) VALUES(?)"); +$sth2 = $dbh->prepare("INSERT INTO phptest (a,b) VALUES(?,?)"); +$sth3 = $dbh->prepare("INSERT INTO phptest (a,b,c) VALUES(?,?,&)"); +print "sth1,sth2,sth3 created\n"; +$tmpfile = tempnam("/tmp", "phptmp"); +register_shutdown_function("my_shutdown"); +$fp = fopen($tmpfile, "w"); +fwrite($fp, "opaque\nplaceholder\ntest"); +fclose($fp); +if (($res = $dbh->execute($sth1, array(72))) == DB_OK) { + print "sth1 executed\n"; +} +if (($res = $dbh->execute($sth2, array(72,'bing'))) == DB_OK) { + print "sth2 executed\n"; +} +if (($res = $dbh->execute($sth3, array(72,'gazonk',$tmpfile))) == DB_OK) { + print "sth3 executed\n"; +} +print "results:\n"; +$sth = $dbh->query("SELECT * FROM phptest WHERE a = 72"); +while ($row = $sth->fetchRow(DB_FETCHMODE_ORDERED)) { + print implode(" - ", $row) . "\n"; +} + +function my_shutdown() { + global $tmpfile; + unlink($tmpfile); +} + +?> Index: pear/DB/tests/sequences.inc diff -u /dev/null pear/DB/tests/sequences.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/sequences.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,79 @@ +<?php // -*- PHP -*- + +function error_handler(&$obj) { + print "sequences.inc error_handler\n"; +} +ob_implicit_flush(true); +$dbh->dropSequence("test"); + +// 1) test that sequences are not created if "ondemand" is false + +$e = $dbh->nextId("test", false); +if (DB::isError($e)) { + print $e->getMessage() . "\n"; +} else { + print "test 1) failed!\n"; +} + +// 2) test that the sequence is not created but the error is +// handled by the class error handler +$dbh->setErrorHandling(PEAR_ERROR_PRINT, "%s <- good error catched\n"); +$e = $dbh->nextId("test", false); +if (!DB::isError($e)) { + print "test 2) failed!\n"; +} +$dbh->_default_error_mode = null; + +// 3) test that sequences are created if "ondemand" is true, and that +// two successive nextIds return adjacent values +$a = $dbh->nextId("test"); +$b = $dbh->nextId("test"); +if (DB::isError($a)) { + print "a: ".$a->toString()."\n"; +} else { + print "a=$a\n"; +} +if (DB::isError($b)) { + print "b: ".$b->toString()."\n"; +} else { + print "b=$b\n"; +} +print "b-a=".($b-$a)."\n"; + +// 4) test that the user-specified error handler is really disabled +// during nextId, with per-object handler as well as global handler +$dbh->dropSequence("test"); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "error_handler"); +$c = $dbh->nextId("test"); +if (DB::isError($c)) { + print "c: ".$c->toString()."\n"; +} else { + print "c=$c\n"; +} +$dbh->dropSequence("test"); +$dbh->_default_error_mode = null; +PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "error_handler"); +$d = $dbh->nextId("test"); +if (DB::isError($d)) { + print "d: ".$d->toString()."\n"; +} else { + print "d=$d\n"; +} + +// 5) test that the sequence is handled right when the table is empty + +// Backend with real sequences may don't like that +PEAR::pushErrorHandling(PEAR_ERROR_RETURN); +$dbh->query('DELETE FROM test_seq'); +PEAR::popErrorHandling(); +$e = $dbh->nextID('test'); +if (DB::isError($d)) { + print "e: ".$d->toString()."\n"; +} else { + print "e=$d\n"; +} + +// final clean-up +$dbh->dropSequence("test"); + +?> Index: pear/DB/tests/simplequery.inc diff -u /dev/null pear/DB/tests/simplequery.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/simplequery.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,7 @@ +<?php + +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$sth = $dbh->simpleQuery("SELECT * FROM phptest"); +print gettype($sth)."\n"; + +?> Index: pear/DB/tests/tableinfo.inc diff -u /dev/null pear/DB/tests/tableinfo.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/tableinfo.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,91 @@ +<?php +function pe($o){ + die($o->toString()); +} +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest_fk"); + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK,'pe'); + +$dbh->query("DELETE FROM phptest"); +$dbh->query("INSERT INTO phptest VALUES(1, 'one', 'One', '2001-02-16')"); +$dbh->query("INSERT INTO phptest VALUES(2, 'two', 'Two', '2001-02-15')"); +$dbh->query("INSERT INTO phptest VALUES(3, 'three', 'Three', '2001-02-14')"); + +$test_mktable_query2 = "CREATE TABLE phptest_fk (a INTEGER, fk INTEGER, c TEXT, d DATE)"; +$dbh->query($test_mktable_query2); + +$dbh->query("INSERT INTO phptest_fk VALUES(1, 1, 'One', '2001-02-16')"); +$dbh->query("INSERT INTO phptest_fk VALUES(2, 1, ' Two', '2001-02-15')"); +$dbh->query("INSERT INTO phptest_fk VALUES(3, 2, 'Three', '2001-02-14')"); + + + +print "testing tableInfo:\n"; +$sth = $dbh->query("SELECT * FROM phptest left join phptest_fk on phptest.a = phptest_fk.fk"); + +$tableInfo = $sth->tableInfo(); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\neight (last) field:\n"; +print_foreach($tableInfo[7]) ; + +print "\ntesting tableInfo (DB_TABLEINFO_ORDER):\n"; +$tableInfo =$sth->tableInfo(DB_TABLEINFO_ORDER); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\neight field:\n"; +print_foreach($tableInfo[3]) ; +print "\nnum_fields:\n"; +print "$tableInfo[num_fields]\n" ; +print "\norder:\n"; +print_foreach($tableInfo['order']) ; + +print "\ntesting tableInfo (DB_TABLEINFO_ORDERTABLE):\n"; +$tableInfo =$sth->tableInfo(DB_TABLEINFO_ORDERTABLE); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\neight field:\n"; +print_foreach($tableInfo[3]) ; +print "\nnum_fields:\n"; +print "$tableInfo[num_fields]\n" ; +print "\nordertable:\n"; +print_foreach($tableInfo['ordertable']) ; +print "\nordertable[phptest]:\n"; +print_foreach($tableInfo['ordertable']['phptest']) ; +print "\nordertable[phptest_fk]:\n"; +print_foreach($tableInfo['ordertable']['phptest_fk']) ; + +print "\ntesting tableInfo (table without query-result):\n"; + +$tableInfo = $dbh->tableInfo("phptest"); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\nfourth (last) field:\n"; +print_foreach($tableInfo[3]) ; + +print "\ntesting tableInfo (table without query-result and DB_TABLEINFO_FULL):\n"; + +$tableInfo = $dbh->tableInfo("phptest",DB_TABLEINFO_FULL); +print "\nfirst field:\n"; +print_foreach($tableInfo[0]) ; +print "\norder:\n"; +print_foreach($tableInfo['order']) ; +print "\nordertable:\n"; +print_foreach($tableInfo['ordertable']) ; +print "\nordertable[phptest]:\n"; +print_foreach($tableInfo['ordertable']['phptest']) ; + + + +//print_foreach($tableInfo[0]) ; +$dbh->query("DELETE FROM phptest WHERE a <> 42"); +$dbh->query("DROP TABLE phptest_fk"); + +function print_foreach ($array) { + foreach ($array as $key => $value) { + print "$key => $value \n"; + } + +} +?> Index: pear/DB/tests/transactions.inc diff -u /dev/null pear/DB/tests/transactions.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/transactions.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,52 @@ +<?php + +// View the table from a separate connection so we don't disturb +// the transaction. +$dbh2 = DB::connect($dbh->dsn); + +function dumptable() { + global $dbh, $dbh2; + printf("%s ops=%d\n", implode(" ", $dbh->getCol("SELECT b FROM phptest")), + $dbh->transaction_opcount); +} +$dbh->setErrorHandling(PEAR_ERROR_DIE); +$dbh->autoCommit(true); +$dbh->query("INSERT INTO phptest VALUES(1, 'one', 'One', '2001-02-19')"); +print "after autocommit: "; +dumptable(); +$dbh->autoCommit(false); +$dbh->query("INSERT INTO phptest VALUES(2, 'two', 'Two', '2001-02-20')"); +$dbh->query("INSERT INTO phptest VALUES(3, 'three', 'Three', '2001-02-21')"); +print "before commit: "; +dumptable(); +$dbh->commit(); +print "after commit: "; +dumptable(); +$dbh->query("INSERT INTO phptest VALUES(4, 'four', 'Four', '2001-02-22')"); +$dbh->query("INSERT INTO phptest VALUES(5, 'five', 'Five', '2001-02-23')"); +print "before rollback: "; +dumptable(); +$dbh->rollback(); +print "after rollback: "; +dumptable(); +$dbh->autoCommit(true); +$dbh->query("INSERT INTO phptest VALUES(6, 'six', 'Six', '2001-02-24')"); +$dbh->query("INSERT INTO phptest VALUES(7, 'seven', 'Seven', '2001-02-25')"); +print "before autocommit+rollback: "; +dumptable(); +$dbh->rollback(); +print "after autocommit+rollback: "; +dumptable(); + +print "testing that select doesn't disturbe opcount: "; +$dbh->autoCommit(false); +$dbh->simpleQuery("SELECT * FROM phptest"); +$dbh->simpleQuery("SELECT a,c FROM phptest"); +$dbh->simpleQuery("SELECT b,d FROM phptest"); +if ($dbh->transaction_opcount == 0) { + print "ok\n"; +} else { + print "failed (count=$dbh->transaction_opcount)\n"; +} + +?> Index: pear/DB/tests/driver/.cvsignore diff -u /dev/null pear/DB/tests/driver/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/.cvsignore Sun May 12 03:29:24 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/driver/01connect.phpt diff -u /dev/null pear/DB/tests/driver/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/01connect.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_driver::connect test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/driver/02fetch.phpt diff -u /dev/null pear/DB/tests/driver/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/02fetch.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,37 @@ +--TEST-- +DB_driver::fetch test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/driver/03simplequery.phpt diff -u /dev/null pear/DB/tests/driver/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/03simplequery.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,11 @@ +--TEST-- +DB_driver::simpleQuery test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/driver/04numcols.phpt diff -u /dev/null pear/DB/tests/driver/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/04numcols.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,14 @@ +--TEST-- +DB_driver::numCols test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/driver/05sequences.phpt diff -u /dev/null pear/DB/tests/driver/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/05sequences.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,18 @@ +--TEST-- +DB_driver::sequences +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +DB Error: no such table <- good error catched +a=1 +b=2 +b-a=1 +c=1 +d=1 +e=1 Index: pear/DB/tests/driver/06prepexec.phpt diff -u /dev/null pear/DB/tests/driver/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/06prepexec.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,20 @@ +--TEST-- +DB_driver::prepare/execute test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/driver/08affectedrows.phpt diff -u /dev/null pear/DB/tests/driver/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/08affectedrows.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,34 @@ +--TEST-- +DB_driver::affectedRows test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +// Clean table +$dbh->query("DELETE FROM phptest"); + +// Affected rows by INSERT statement +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); + +// Affected rows by SELECT statement +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); + +// Affected rows by DELETE statement +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->setOption("optimize", "portability"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all (optimize=%s)\n", $dbh->affectedRows(), + $dbh->getOption("optimize")); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +2 after delete all (optimize=portability) Index: pear/DB/tests/driver/09numrows.phpt diff -u /dev/null pear/DB/tests/driver/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/09numrows.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_driver::numRows test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 Index: pear/DB/tests/driver/10errormap.phpt diff -u /dev/null pear/DB/tests/driver/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/10errormap.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,27 @@ +--TEST-- +DB_driver::error mapping +--SKIPIF-- +<?php chdir(dirname(__FILE__)); 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 + DB Error: constraint violation +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 Index: pear/DB/tests/driver/13limit.phpt diff -u /dev/null pear/DB/tests/driver/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/13limit.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_driver::row limit +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include '../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/driver/14fetchmode_object.phpt diff -u /dev/null pear/DB/tests/driver/14fetchmode_object.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/14fetchmode_object.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_driver::fetchmode object +--SKIPIF-- +<?php chdir(dirname(__FILE__)); require "skipif.inc"; ?> +--FILE-- +<?php +require './connect.inc'; +include '../fetchmode_object.inc'; +?> +--EXPECT-- +--- fetch with param DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row --- +db_row -> a b c d +db_row -> a b c d Index: pear/DB/tests/driver/15quote.phpt diff -u /dev/null pear/DB/tests/driver/15quote.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/15quote.phpt Sun May 12 03:29:24 2002 @@ -0,0 +1,67 @@ +--TEST-- +DB_driver::escape data test +--SKIPIF-- +<?php chdir(dirname(__FILE__)); include("skipif.inc"); ?> +--FILE-- +<?php +include './connect.inc'; +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'debug_die'); + +$dbh->expectError(DB_ERROR_ALREADY_EXISTS); +$dbh->query("CREATE TABLE pearquote (n FLOAT, s VARCHAR(8))"); +$dbh->popExpect(); + +$dbh->query("DELETE FROM pearquote"); + +$strings = array( + "'", + "\"", + "\\", + "%", + "_", + "''", + "\"\"", + "\\\\", + "\\'\\'", + "\\\"\\\"" +); +$nums = array( + 156, + 12.3, + '15', + '12.3' +); + +echo "String escape test: "; +foreach ($strings as $s) { + $quoted = $dbh->quote($s); + $dbh->query("INSERT INTO pearquote VALUES (1, $quoted)"); +} +$diff = array_diff($strings, $res = $dbh->getCol("SELECT s FROM pearquote")); +if (count($diff) > 0) { + echo "FAIL"; + print_r($strings); + print_r($res); +} else { + echo "OK"; +} + +$dbh->query("DELETE FROM pearquote"); + +echo "\nNumber escape test: "; +foreach ($nums as $n) { + $quoted = $dbh->quote($n); + $dbh->query("INSERT INTO pearquote VALUES ($quoted, 'foo')"); +} +$diff = array_diff($nums, $res = $dbh->getCol("SELECT n FROM pearquote")); +if (count($diff) > 0) { + echo "FAIL"; + print_r($nums); + print_r($res); +} else { + echo "OK\n"; +} +?> +--EXPECT-- +String escape test: OK +Number escape test: OK Index: pear/DB/tests/driver/connect.inc diff -u /dev/null pear/DB/tests/driver/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/connect.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,14 @@ +<?php +require './setup.inc'; +error_reporting(E_ALL); +require_once "DB.php"; +$dbh = DB::connect(DRIVER_DSN, array('optimize' => 'portability')); +if (DB::isError($dbh)) { + die("connect.inc: ".$dbh->toString()); +} + +function debug_die($o){ + die($o->toString()); +} + +?> Index: pear/DB/tests/driver/mktable.inc diff -u /dev/null pear/DB/tests/driver/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/mktable.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,15 @@ +<?php +require_once "./connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +//$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'debug_die'); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c VARCHAR(255), d VARCHAR(20))"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/driver/setup.inc diff -u /dev/null pear/DB/tests/driver/setup.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/setup.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,7 @@ +<?php +ini_set('include_path','.:'.PHP_LIBDIR); +define('DRIVER_DSN', ''); +//define('DRIVER_DSN', 'pgsql://postgres@localhost/test'); +//define('DRIVER_DSN', 'mysql://root@localhost/test'); +//define('DRIVER_DSN', 'oci8://system:manager@'); +?> \ No newline at end of file Index: pear/DB/tests/driver/skipif.inc diff -u /dev/null pear/DB/tests/driver/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/driver/skipif.inc Sun May 12 03:29:24 2002 @@ -0,0 +1,17 @@ +<?php +// This script prints "skip" unless: +// * the mysql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +include './setup.inc'; +require_once 'DB.php'; +if (!defined('DRIVER_DSN') || DRIVER_DSN == '') { + die("skip\n"); +} +$db = DB::connect(DRIVER_DSN); +if (DB::isError($db)) { + die("skip\n"); +} +?> \ No newline at end of file Index: pear/DB/tests/ibase/.cvsignore diff -u /dev/null pear/DB/tests/ibase/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/.cvsignore Sun May 12 03:29:25 2002 @@ -0,0 +1,5 @@ +*.exp +*.out +*.php +phpt.* +test.gdb Index: pear/DB/tests/ibase/01connect.phpt diff -u /dev/null pear/DB/tests/ibase/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/01connect.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_ibase::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/ibase/02fetch.phpt diff -u /dev/null pear/DB/tests/ibase/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/02fetch.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_ibase fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../fetchrow.inc"); +include(dirname(__FILE__)."/../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/ibase/03simplequery.phpt diff -u /dev/null pear/DB/tests/ibase/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/03simplequery.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_ibase::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/ibase/04numcols.phpt diff -u /dev/null pear/DB/tests/ibase/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/04numcols.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_ibase::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/ibase/06prepexec.phpt diff -u /dev/null pear/DB/tests/ibase/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/06prepexec.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_ibase::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/ibase/10errormap.phpt diff -u /dev/null pear/DB/tests/ibase/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/10errormap.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,26 @@ +--TEST-- +DB_ibase error mapping +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require dirname(__FILE__)."/../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 Index: pear/DB/tests/ibase/connect.inc diff -u /dev/null pear/DB/tests/ibase/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/connect.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,5 @@ +<?php +require_once "DB.php"; +$dbh = DB::connect("ibase://localhost/" . dirname(__FILE__). "/test.gdb?dialect=3", array('optimize'=>'portability')); +ibase_timefmt("%Y-%m-%d", IBASE_DATE); +?> Index: pear/DB/tests/ibase/mktable.inc diff -u /dev/null pear/DB/tests/ibase/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/mktable.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c VARCHAR(1024), d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/ibase/skipif.inc diff -u /dev/null pear/DB/tests/ibase/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/ibase/skipif.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,17 @@ +<?php +// This script prints "skip" unless: +// * the ibase extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +if (!extension_loaded("interbase") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("interbase$dlext"); +} +if (!extension_loaded("interbase")) { + die("skip\n"); +} +$conn = @ibase_connect("pear/DB/tests/ibase/test.gdb"); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/mysql/.cvsignore diff -u /dev/null pear/DB/tests/mysql/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/.cvsignore Sun May 12 03:29:25 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/mysql/01connect.phpt diff -u /dev/null pear/DB/tests/mysql/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/01connect.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_mysql::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/mysql/02fetch.phpt diff -u /dev/null pear/DB/tests/mysql/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/02fetch.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_mysql fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../fetchrow.inc"); +include(dirname(__FILE__)."/../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/mysql/03simplequery.phpt diff -u /dev/null pear/DB/tests/mysql/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/03simplequery.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_mysql::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/mysql/04numcols.phpt diff -u /dev/null pear/DB/tests/mysql/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/04numcols.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_mysql::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/mysql/05sequences.phpt diff -u /dev/null pear/DB/tests/mysql/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/05sequences.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,18 @@ +--TEST-- +DB_mysql sequences +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require dirname(__FILE__)."/../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +DB Error: no such table <- good error catched +a=1 +b=2 +b-a=1 +c=1 +d=1 +e=1 Index: pear/DB/tests/mysql/06prepexec.phpt diff -u /dev/null pear/DB/tests/mysql/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/06prepexec.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_mysql::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/mysql/07errornative.phpt diff -u /dev/null pear/DB/tests/mysql/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/07errornative.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,13 @@ +--TEST-- +DB_mysql::errorNative test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("syntax error please"); +print "error code " . $dbh->errorNative() . "\n"; +?> +--EXPECT-- +error code 1064 Index: pear/DB/tests/mysql/08affectedrows.phpt diff -u /dev/null pear/DB/tests/mysql/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/08affectedrows.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,33 @@ +--TEST-- +DB_mysql::affectedRows test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all (optimize=%s)\n", $dbh->affectedRows(), + $dbh->getOption("optimize")); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->setOption("optimize", "portability"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all (optimize=%s)\n", $dbh->affectedRows(), + $dbh->getOption("optimize")); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +0 after delete all (optimize=performance) +2 after delete all (optimize=portability) Index: pear/DB/tests/mysql/09numrows.phpt diff -u /dev/null pear/DB/tests/mysql/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/09numrows.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_mysql::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require dirname(__FILE__)."/../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 Index: pear/DB/tests/mysql/10errormap.phpt diff -u /dev/null pear/DB/tests/mysql/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/10errormap.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,24 @@ +--TEST-- +DB_mysql error mapping +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require dirname(__FILE__)."/../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: pear/DB/tests/mysql/12tableinfo.phpt diff -u /dev/null pear/DB/tests/mysql/12tableinfo.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/12tableinfo.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,127 @@ +--TEST-- +DB_mysql tableInfo test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include(dirname(__FILE__)."/../tableinfo.inc"); +?> +--EXPECT-- +testing tableInfo: + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +eight (last) field: +table => phptest_fk +name => d +type => date +len => 10 +flags => + +testing tableInfo (DB_TABLEINFO_ORDER): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +eight field: +table => phptest +name => d +type => date +len => 10 +flags => + +num_fields: +8 + +order: +a => 4 +b => 1 +c => 6 +d => 7 +fk => 5 + +testing tableInfo (DB_TABLEINFO_ORDERTABLE): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +eight field: +table => phptest +name => d +type => date +len => 10 +flags => + +num_fields: +8 + +ordertable: +phptest => Array +phptest_fk => Array + +ordertable[phptest]: +a => 0 +b => 1 +c => 2 +d => 3 + +ordertable[phptest_fk]: +a => 4 +fk => 5 +c => 6 +d => 7 + +testing tableInfo (table without query-result): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +fourth (last) field: +table => phptest +name => d +type => date +len => 10 +flags => + +testing tableInfo (table without query-result and DB_TABLEINFO_FULL): + +first field: +table => phptest +name => a +type => int +len => 11 +flags => + +order: +a => 0 +b => 1 +c => 2 +d => 3 + +ordertable: +phptest => Array + +ordertable[phptest]: +a => 0 +b => 1 +c => 2 +d => 3 Index: pear/DB/tests/mysql/13limit.phpt diff -u /dev/null pear/DB/tests/mysql/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/13limit.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_mysql row limit +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include dirname(__FILE__).'/../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/mysql/14fetchmode_object.phpt diff -u /dev/null pear/DB/tests/mysql/14fetchmode_object.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/14fetchmode_object.phpt Sun May 12 03:29:25 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_mysql::fetchmode object +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include dirname(__FILE__).'/../fetchmode_object.inc'; +?> +--EXPECT-- +--- fetch with param DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row --- +db_row -> a b c d +db_row -> a b c d Index: pear/DB/tests/mysql/connect.inc diff -u /dev/null pear/DB/tests/mysql/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/connect.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,7 @@ +<?php +require_once "DB.php"; +$dbh = DB::connect("mysql://localhost/test"); +if (DB::isError($dbh)) { + die("connect.inc: ".$dbh->getMessage()); +} +?> Index: pear/DB/tests/mysql/mktable.inc diff -u /dev/null pear/DB/tests/mysql/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/mktable.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/mysql/skipif.inc diff -u /dev/null pear/DB/tests/mysql/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/mysql/skipif.inc Sun May 12 03:29:25 2002 @@ -0,0 +1,22 @@ +<?php +// This script prints "skip" unless: +// * the mysql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("mysql") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("mysql$dlext"); +} +if (!extension_loaded("mysql")) { + die("skip\n"); +} +$conn = @mysql_connect("localhost"); +if (!is_resource($conn)) { + die("skip\n"); +} +if (!mysql_select_db("test", $conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/oci8/.cvsignore diff -u /dev/null pear/DB/tests/oci8/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/.cvsignore Sun May 12 03:29:26 2002 @@ -0,0 +1,5 @@ +*.exp +*.out +*.php +phpt.* +sqlnet.log Index: pear/DB/tests/oci8/01connect.phpt diff -u /dev/null pear/DB/tests/oci8/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/01connect.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_oci8::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/oci8/02fetch.phpt diff -u /dev/null pear/DB/tests/oci8/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/02fetch.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,37 @@ +--TEST-- +DB_oci8::fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +A B C D +testing fetchmodes: fetchrow ordered default with assoc specified +A B C D +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +A B C D +testing fetchmodes: fetchinto ordered default with assoc specified +A B C D +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/oci8/03simplequery.phpt diff -u /dev/null pear/DB/tests/oci8/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/03simplequery.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,11 @@ +--TEST-- +DB_oci8::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/oci8/04numcols.phpt diff -u /dev/null pear/DB/tests/oci8/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/04numcols.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,14 @@ +--TEST-- +DB_oci8::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/oci8/05sequences.phpt diff -u /dev/null pear/DB/tests/oci8/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/05sequences.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,18 @@ +--TEST-- +DB_oci8::sequences +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require dirname(__FILE__)."/../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +DB Error: no such table <- good error catched +a=1 +b=2 +b-a=1 +c=1 +d=1 +e=1 Index: pear/DB/tests/oci8/06prepexec.phpt diff -u /dev/null pear/DB/tests/oci8/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/06prepexec.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,20 @@ +--TEST-- +DB_oci8::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/oci8/07errornative.phpt diff -u /dev/null pear/DB/tests/oci8/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/07errornative.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,11 @@ +--TEST-- +DB_oci8::errorNative test +--SKIPIF-- +<?php /*include("skipif.inc");*/ print "skip\n"; ?> +--FILE-- +<?php +include("mktable.inc"); +$err = $dbh->query("SELECT foo FROM tablethatdoesnotexist"); +print $dbh->errorNative() . "\n"; +?> +--EXPECT-- Index: pear/DB/tests/oci8/08affectedrows.phpt diff -u /dev/null pear/DB/tests/oci8/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/08affectedrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,24 @@ +--TEST-- +DB_oci8::affectedRows test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +include("mktable.inc"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all\n", $dbh->affectedRows()); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +3 after delete all Index: pear/DB/tests/oci8/09numrows.phpt diff -u /dev/null pear/DB/tests/oci8/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/09numrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,34 @@ +--TEST-- +DB_oci8::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +$dbh->autoCommit(false); +$dbh->setOption("optimize", "portability"); +$test_error_mode = PEAR_ERROR_PRINT; +include "../numrows.inc"; +$dbh->rollback(); +$dbh->setOption("optimize", "performance"); +include "../numrows.inc"; +$dbh->rollback(); +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable +DB Error: DB backend not capable Index: pear/DB/tests/oci8/10errormap.phpt diff -u /dev/null pear/DB/tests/oci8/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/10errormap.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,27 @@ +--TEST-- +DB_oci8::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 + DB Error: constraint violation +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 Index: pear/DB/tests/oci8/13limit.phpt diff -u /dev/null pear/DB/tests/oci8/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/13limit.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_oci8::row limit +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include '../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/oci8/connect.inc diff -u /dev/null pear/DB/tests/oci8/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/connect.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,9 @@ +<?php +$path = dirname(__FILE__) . "/../../.."; +ini_set('include_path', realpath($path)); +require_once "DB.php"; +$dbh = DB::connect("oci8://system:manager@test", array('debug' => 2)); +if (PEAR::isError($dbh)) { + die($dbh->tostring()); +} +?> Index: pear/DB/tests/oci8/mktable.inc diff -u /dev/null pear/DB/tests/oci8/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/mktable.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,20 @@ +<?php + +require_once dirname(__FILE__)."/connect.inc"; + +function mktable_error_handler($errobj) { + print "mktable error: ".$errobj->getMessage().": ".$errobj->getUserInfo(); + print "\n"; + exit; +} +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, "mktable_error_handler"); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR2(40), c LONG VARCHAR, d VARCHAR2(20))"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/oci8/skipif.inc diff -u /dev/null pear/DB/tests/oci8/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/oci8/skipif.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,17 @@ +<?php +// This script prints "skip" unless: +// * the ibase extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +if (!extension_loaded("oci8") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("oci8$dlext"); +} +if (!extension_loaded("oci8")) { + die("skip\n"); +} +$conn = @OCILogon("system", "manager", "test"); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/odbc/.cvsignore diff -u /dev/null pear/DB/tests/odbc/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/.cvsignore Sun May 12 03:29:26 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/odbc/01connect.phpt diff -u /dev/null pear/DB/tests/odbc/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/01connect.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,18 @@ +--TEST-- +ODBC DB::connect +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/odbc/02fetch.phpt diff -u /dev/null pear/DB/tests/odbc/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/02fetch.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_odbc fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 1999-11-21 +row 2: 1, one, One, 2001-02-16 +row 3: 2, two, Two, 2001-02-15 +row 4: 3, three, Three, 2001-02-14 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/odbc/03simplequery.phpt diff -u /dev/null pear/DB/tests/odbc/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/03simplequery.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_odbc::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/odbc/04numcols.phpt diff -u /dev/null pear/DB/tests/odbc/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/04numcols.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_odbc::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/odbc/06prepexec.phpt diff -u /dev/null pear/DB/tests/odbc/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/06prepexec.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_odbc::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/odbc/07errornative.phpt diff -u /dev/null pear/DB/tests/odbc/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/07errornative.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,13 @@ +--TEST-- +DB_odbc::errorNative test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("syntax error please"); +print "error code " . $dbh->errorNative() . "\n"; +?> +--EXPECT-- +error code 1064 Index: pear/DB/tests/odbc/09numrows.phpt diff -u /dev/null pear/DB/tests/odbc/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/09numrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,20 @@ +--TEST-- +DB_odbc::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 +DB Error: unknown error Index: pear/DB/tests/odbc/10errormap.phpt diff -u /dev/null pear/DB/tests/odbc/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/10errormap.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,24 @@ +--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: pear/DB/tests/odbc/connect.inc diff -u /dev/null pear/DB/tests/odbc/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/connect.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,11 @@ +<?php +require_once "DB.php"; +require "dsn.inc"; +if (!$dsn) { + die("tests not configure for this environment"); +} +$dbh = DB::connect($dsn); +if (DB::isError($dbh)) { + die("connect.inc: ".$dbh->getMessage()); +} +?> Index: pear/DB/tests/odbc/dsn.inc diff -u /dev/null pear/DB/tests/odbc/dsn.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/dsn.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +<?php + +switch (ODBC_TYPE) { + case "solid": + $nativedsn = "tcp localhost 1313"; + $dsn = "odbc://tcp+localhost+1313"; + $user = $pass = "test"; + break; + case "iodbc": + $nativedsn = "test"; + $dsn = "odbc://test"; + $user = $pass = ""; + break; + default: + $nativedsn = $dsn = $user = $pass = ""; + break; +} + +?> Index: pear/DB/tests/odbc/mktable.inc diff -u /dev/null pear/DB/tests/odbc/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/mktable.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/odbc/skipif.inc diff -u /dev/null pear/DB/tests/odbc/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/odbc/skipif.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,23 @@ +<?php +// This script prints "skip" unless: +// * the odbc extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("odbc") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("odbc$dlext"); +} +if (!extension_loaded("odbc")) { + die("skip\n"); +} +require "dsn.inc"; +if (!$nativedsn) { + die("skip\n"); +} +$conn = @odbc_connect($nativedsn, $user, $pass); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/pgsql/.cvsignore diff -u /dev/null pear/DB/tests/pgsql/.cvsignore:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/.cvsignore Sun May 12 03:29:26 2002 @@ -0,0 +1,4 @@ +*.exp +*.out +*.php +phpt.* Index: pear/DB/tests/pgsql/01connect.phpt diff -u /dev/null pear/DB/tests/pgsql/01connect.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/01connect.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,17 @@ +--TEST-- +DB_pgsql::connect test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +if (is_object($dbh)) { + print "\$dbh is an object\n"; +} +if (is_resource($dbh->connection)) { + print "\$dbh is connected\n"; +} +?> +--EXPECT-- +$dbh is an object +$dbh is connected Index: pear/DB/tests/pgsql/02fetch.phpt diff -u /dev/null pear/DB/tests/pgsql/02fetch.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/02fetch.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,38 @@ +--TEST-- +DB_pgsql fetch test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../fetchrow.inc"); +include("../fetchmodes.inc"); +?> +--EXPECT-- +testing fetchrow: +row 1: 42, bing, This is a test, 11-21-1999 +row 2: 1, one, One, 02-16-2001 +row 3: 2, two, Two, 02-15-2001 +row 4: 3, three, Three, 02-14-2001 +row 5: NULL +testing fetchmodes: fetchrow default default +0 1 2 3 +testing fetchmodes: fetchinto default default +0 1 2 3 +testing fetchmodes: fetchrow ordered default +0 1 2 3 +testing fetchmodes: fetchrow assoc default +a b c d +testing fetchmodes: fetchrow ordered default with assoc specified +a b c d +testing fetchmodes: fetchrow assoc default with ordered specified +0 1 2 3 +testing fetchmodes: fetchinto ordered default +0 1 2 3 +testing fetchmodes: fetchinto assoc default +a b c d +testing fetchmodes: fetchinto ordered default with assoc specified +a b c d +testing fetchmodes: fetchinto assoc default with ordered specified +0 1 2 3 Index: pear/DB/tests/pgsql/03simplequery.phpt diff -u /dev/null pear/DB/tests/pgsql/03simplequery.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/03simplequery.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,12 @@ +--TEST-- +DB_pgsql::simpleQuery test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../simplequery.inc"); +?> +--EXPECT-- +resource Index: pear/DB/tests/pgsql/04numcols.phpt diff -u /dev/null pear/DB/tests/pgsql/04numcols.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/04numcols.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +--TEST-- +DB_pgsql::numCols test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../numcols.inc"); +?> +--EXPECT-- +1 +2 +3 +4 Index: pear/DB/tests/pgsql/05sequences.phpt diff -u /dev/null pear/DB/tests/pgsql/05sequences.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/05sequences.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,16 @@ +--TEST-- +DB_pgsql sequences +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "../sequences.inc"; +?> +--EXPECT-- +DB Error: no such table +a=1 +b=2 +b-a=1 +c=1 +d=1 Index: pear/DB/tests/pgsql/06prepexec.phpt diff -u /dev/null pear/DB/tests/pgsql/06prepexec.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/06prepexec.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,21 @@ +--TEST-- +DB_pgsql::prepare/execute test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +include("../prepexe.inc"); +?> +--EXPECT-- +sth1,sth2,sth3 created +sth1 executed +sth2 executed +sth3 executed +results: +72 - - - +72 - bing - - +72 - gazonk - opaque +placeholder +test - Index: pear/DB/tests/pgsql/07errornative.phpt diff -u /dev/null pear/DB/tests/pgsql/07errornative.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/07errornative.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,13 @@ +--TEST-- +DB_pgsql::errorNative test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("syntax error please"); +print $dbh->errorNative() . "\n"; +?> +--EXPECT-- +ERROR: parser: parse error at or near "syntax" Index: pear/DB/tests/pgsql/08affectedrows.phpt diff -u /dev/null pear/DB/tests/pgsql/08affectedrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/08affectedrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,25 @@ +--TEST-- +DB_pgsql::affectedRows test +--SKIPIF-- +<?php include("skipif.inc"); ?> +--FILE-- +<?php +require_once "DB.php"; +include("mktable.inc"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +printf("%d after insert\n", $dbh->affectedRows()); +$dbh->query("SELECT * FROM phptest"); +printf("%d after select\n", $dbh->affectedRows()); +$dbh->query("DELETE FROM phptest WHERE b = 'test'"); +printf("%d after delete\n", $dbh->affectedRows()); +$dbh->query("INSERT INTO phptest (a,b) VALUES(1, 'test')"); +$dbh->query("INSERT INTO phptest (a,b) VALUES(2, 'test')"); +$dbh->query("DELETE FROM phptest"); +printf("%d after delete all\n", $dbh->affectedRows()); +?> +--EXPECT-- +1 after insert +0 after select +2 after delete +3 after delete all Index: pear/DB/tests/pgsql/09numrows.phpt diff -u /dev/null pear/DB/tests/pgsql/09numrows.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/09numrows.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_pgsql::numRows test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../numrows.inc"; +?> +--EXPECT-- +1 +2 +3 +4 +5 +6 +2 +0 Index: pear/DB/tests/pgsql/10errormap.phpt diff -u /dev/null pear/DB/tests/pgsql/10errormap.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/10errormap.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,28 @@ +--TEST-- +DB_pgsql error mapping +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +// The DB_ERROR_CONSTRAINT test will fail on PostgreSQL < 7.x +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 + DB Error: constraint violation +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 Index: pear/DB/tests/pgsql/11transact.phpt diff -u /dev/null pear/DB/tests/pgsql/11transact.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/11transact.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_pgsql transaction test +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require "connect.inc"; +require "mktable.inc"; +require "../transactions.inc"; +?> +--EXPECT-- +after autocommit: bing one ops=0 +before commit: bing one two three ops=2 +after commit: bing one two three ops=0 +before rollback: bing one two three four five ops=2 +after rollback: bing one two three ops=0 +before autocommit+rollback: bing one two three six seven ops=0 +after autocommit+rollback: bing one two three six seven ops=0 +testing that select doesn't disturbe opcount: ok Index: pear/DB/tests/pgsql/13limit.phpt diff -u /dev/null pear/DB/tests/pgsql/13limit.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/13limit.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,47 @@ +--TEST-- +DB_pgsql row limit +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require 'connect.inc'; +include '../limit.inc'; +?> +--EXPECT-- +======= From: 0 || Number of rows to fetch: 10 ======= +1.- result 0 +2.- result 1 +3.- result 2 +4.- result 3 +5.- result 4 +6.- result 5 +7.- result 6 +8.- result 7 +9.- result 8 +10.- result 9 +======= From: 10 || Number of rows to fetch: 10 ======= +11.- result 10 +12.- result 11 +13.- result 12 +14.- result 13 +15.- result 14 +16.- result 15 +17.- result 16 +18.- result 17 +19.- result 18 +20.- result 19 +======= From: 20 || Number of rows to fetch: 10 ======= +21.- result 20 +22.- result 21 +23.- result 22 +24.- result 23 +25.- result 24 +26.- result 25 +27.- result 26 +28.- result 27 +29.- result 28 +30.- result 29 +======= From: 30 || Number of rows to fetch: 10 ======= +31.- result 30 +32.- result 31 +33.- result 32 Index: pear/DB/tests/pgsql/14fetchmode_object.phpt diff -u /dev/null pear/DB/tests/pgsql/14fetchmode_object.phpt:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/14fetchmode_object.phpt Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +--TEST-- +DB_pgsql::fetchmode object +--SKIPIF-- +<?php require "skipif.inc"; ?> +--FILE-- +<?php +require './connect.inc'; +include '../fetchmode_object.inc'; +?> +--EXPECT-- +--- fetch with param DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT --- +stdClass -> a b c d +stdClass -> a b c d +--- fetch with default fetchmode DB_FETCHMODE_OBJECT and class DB_Row --- +db_row -> a b c d +db_row -> a b c d Index: pear/DB/tests/pgsql/connect.inc diff -u /dev/null pear/DB/tests/pgsql/connect.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/connect.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,4 @@ +<?php +require_once "DB.php"; +$dbh = DB::connect("pgsql://unix+localhost/test"); +?> Index: pear/DB/tests/pgsql/mktable.inc diff -u /dev/null pear/DB/tests/pgsql/mktable.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/mktable.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,15 @@ +<?php + +require_once "connect.inc"; + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query("DROP TABLE phptest"); + +$dbh->setErrorHandling(PEAR_ERROR_TRIGGER); +$test_mktable_query = "CREATE TABLE phptest (a INTEGER, b VARCHAR(40), c TEXT, d DATE)"; +$dbh->query($test_mktable_query); +$dbh->query("INSERT INTO phptest VALUES(42, 'bing', 'This is a test', '1999-11-21')"); + +$dbh->setErrorHandling(PEAR_ERROR_RETURN); + +?> Index: pear/DB/tests/pgsql/skipif.inc diff -u /dev/null pear/DB/tests/pgsql/skipif.inc:1.3 --- /dev/null Sun May 12 03:29:27 2002 +++ pear/DB/tests/pgsql/skipif.inc Sun May 12 03:29:26 2002 @@ -0,0 +1,19 @@ +<?php +// This script prints "skip" unless: +// * the pgsql extension is built-in or loadable, AND +// * there is a database called "test" accessible +// with no username/password, AND +// * we have create/drop privileges on the entire "test" +// database +if (!extension_loaded("pgsql") && ini_get("enable_dl")) { + $dlext = (substr(PHP_OS, 0, 3) == "WIN") ? ".dll" : ".so"; + @dl("pgsql$dlext"); +} +if (!extension_loaded("pgsql")) { + die("skip\n"); +} +$conn = @pg_connect("host=localhost dbname=test"); +if (!is_resource($conn)) { + die("skip\n"); +} +?> Index: pear/DB/tests/ibase/05sequences.phpt +++ pear/DB/tests/ibase/05sequences.phpt --TEST-- DB_driver::sequences --SKIPIF-- <?php require "skipif.inc"; ?> --FILE-- <?php /* Test output differs from the standard DB sequences test due to a bug in the php interbase driver, that returns numbers as strings; */ require "connect.inc"; require dirname(__FILE__)."/../sequences.inc"; ?> --EXPECT-- DB Error: unknown error a=1. b=2. b-a=1 c=1. d=1. Index: pear/DB/tests/oci8/12tableinfo.phpt +++ pear/DB/tests/oci8/12tableinfo.phpt --TEST-- DB_oci8::tableInfo test --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php include dirname(__FILE__)."/mktable.inc"; print "Printing output for dbh->tableInfo('phptest')\n"; print_r($dbh->tableInfo('phptest')); print "Printing output for res->tableInfo()\n"; $res = $dbh->query('SELECT * FROM phptest'); print_r($res->tableInfo()); ?> --EXPECT-- Printing output for dbh->tableInfo('phptest') Array ( [0] => Array ( [table] => PHPTEST [name] => A [type] => NUMBER [len] => 22 [format] => [nullable] => 1 [default] => ) [1] => Array ( [table] => PHPTEST [name] => B [type] => VARCHAR2 [len] => 40 [format] => [nullable] => 1 [default] => ) [2] => Array ( [table] => PHPTEST [name] => C [type] => LONG [len] => 0 [format] => [nullable] => 1 [default] => ) [3] => Array ( [table] => PHPTEST [name] => D [type] => VARCHAR2 [len] => 20 [format] => [nullable] => 1 [default] => ) [num_fields] => 4 ) Printing output for res->tableInfo() Array ( [0] => Array ( [name] => A [type] => NUMBER [len] => 22 [table] => A [format] => [nullable] => [default] => ) [1] => Array ( [name] => B [type] => VARCHAR [len] => 40 [table] => B [format] => [nullable] => 1 [default] => ) [2] => Array ( [name] => C [type] => LONG [len] => 2147483647 [table] => PHPTEST [format] => [nullable] => 1 [default] => ) [3] => Array ( [name] => D [type] => VARCHAR [len] => 20 [table] => PHPTEST [format] => [nullable] => 1 [default] => ) [num_fields] => 4 )