Omit warning during autoloading when an included file does not exist.
authorGunnar Wrobel <p@rdus.de>
Thu, 11 Feb 2010 13:48:13 +0000 (14:48 +0100)
committerGunnar Wrobel <p@rdus.de>
Thu, 11 Feb 2010 13:48:13 +0000 (14:48 +0100)
Otherwise some test may fail under strict conditions since
class_exists() and new ReflectionClass() suddenly emit a warning for
non-existant classes. See tests in Horde_Injector that test for
reactions on specifying non existing Instances.

framework/Test/lib/Horde/Test/AllTests.php

index f85863e..3357eb0 100644 (file)
@@ -68,7 +68,16 @@ class Horde_Test_AllTests
         $basedir = dirname(self::$_file);
         set_include_path($basedir . '/../../../lib' . PATH_SEPARATOR . get_include_path());
         if (!spl_autoload_functions()) {
-            spl_autoload_register(create_function('$class', '$filename = str_replace(array(\'\\\\\', \'_\'), \'/\', $class); include "$filename.php";'));
+            spl_autoload_register(
+                create_function(
+                    '$class', 
+                    '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);'
+                    . '$err_mask = E_ALL ^ E_WARNING;'
+                    . '$oldErrorReporting = error_reporting($err_mask);'
+                    . 'include "$filename.php";'
+                    . 'error_reporting($oldErrorReporting);'
+                )
+            );
         }
 
         $suite = new PHPUnit_Framework_TestSuite('Horde Framework - ' . self::$_package);