Non-fatal SQL errors when running unit tests.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 1 May 2010 13:37:49 +0000 (15:37 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 1 May 2010 13:37:49 +0000 (15:37 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/xdb.php
include/test.inc.php

index d9bde66..e715eef 100644 (file)
@@ -22,6 +22,7 @@
 class XDB
 {
     private static $mysqli = null;
+    private static $fatalErrors = true;
 
     public static function connect()
     {
@@ -39,6 +40,11 @@ class XDB
         return true;
     }
 
+    public static function setNonFatalError()
+    {
+        self::$fatalErrors = false;
+    }
+
     public static function _prepare($args)
     {
         global $globals;
@@ -127,8 +133,12 @@ class XDB
                             . "--------------------------------------------------------------------------------\n");
                 fclose($file);
             }
-            Platal::page()->kill($text);
-            exit;
+            if (self::$fatalErrors) {
+                Platal::page()->kill($text);
+                exit;
+            } else {
+                throw new Exception($text . " :\n" . $query);
+            }
         }
         return $res;
     }
index 2a7048e..c5dc418 100644 (file)
@@ -31,6 +31,7 @@ if (file_exists($testinclude)) {
         pl_autoload($class);
     }
 }
+XDB::setNonFatalError();
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>