cvs: pear /DB/tests errors.inc /DB/tests/driver 10errormap.phpt

From: Date: Thu, 19 Feb 2004 07:18:28 +0000
Subject: cvs: pear /DB/tests errors.inc /DB/tests/driver 10errormap.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-16660@lists.php.net to get a copy of this message
danielc Thu Feb 19 02:18:28 2004 EDT Modified files: /pear/DB/tests errors.inc /pear/DB/tests/driver 10errormap.phpt Log: Refine not null constraint tests. http://cvs.php.net/diff.php/pear/DB/tests/errors.inc?r1=1.12&r2=1.13&ty=u Index: pear/DB/tests/errors.inc diff -u pear/DB/tests/errors.inc:1.12 pear/DB/tests/errors.inc:1.13 --- pear/DB/tests/errors.inc:1.12 Wed Feb 18 18:07:11 2004 +++ pear/DB/tests/errors.inc Thu Feb 19 02:18:27 2004 @@ -69,10 +69,18 @@ } -print "Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL\n"; -$dbh->query('INSERT INTO a VALUES (NULL)'); +print "Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL on insert\n"; +$dbh->setErrorHandling(PEAR_ERROR_RETURN); +$dbh->query('DROP TABLE peartestnull'); +$dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'errhandler'); +$dbh->query('CREATE TABLE peartestnull (a CHAR(3) NOT NULL)'); +$dbh->query('INSERT INTO peartestnull VALUES (NULL)'); + +print "Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL on update\n"; +$dbh->query("INSERT INTO peartestnull VALUES ('one')"); +$dbh->query("UPDATE peartestnull SET a = NULL WHERE a = 'one'"); switch ($dbh->phptype) { - case 'sqlite': + case 'mysql': print " $dbh->phptype doesn't consider this an error\n"; break; } @@ -120,5 +128,6 @@ $dbh->query('DROP TABLE phptest'); $dbh->query('DROP TABLE b'); $dbh->query('DROP TABLE a'); +$dbh->query('DROP TABLE peartestnull'); ?> http://cvs.php.net/diff.php/pear/DB/tests/driver/10errormap.phpt?r1=1.7&r2=1.8&ty=u Index: pear/DB/tests/driver/10errormap.phpt diff -u pear/DB/tests/driver/10errormap.phpt:1.7 pear/DB/tests/driver/10errormap.phpt:1.8 --- pear/DB/tests/driver/10errormap.phpt:1.7 Wed Feb 18 18:07:11 2004 +++ pear/DB/tests/driver/10errormap.phpt Thu Feb 19 02:18:28 2004 @@ -24,7 +24,9 @@ DB Error: constraint violation Trying to provoke DB_ERROR_CONSTRAINT for foreign key DB Error: constraint violation -Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL +Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL on insert + DB Error: null value violates not-null constraint +Trying to provoke DB_ERROR_CONSTRAINT_NOT_NULL on update DB Error: null value violates not-null constraint Trying to provoke DB_ERROR_DIVZERO DB Error: division by zero

« previous php.pear.cvs (#16660) next »