Add a fix to ignore the autoloading of the newer PHPUnit (>= 3.5.0, currently RC).
authorGunnar Wrobel <p@rdus.de>
Tue, 24 Aug 2010 08:07:50 +0000 (10:07 +0200)
committerGunnar Wrobel <p@rdus.de>
Tue, 24 Aug 2010 08:56:35 +0000 (10:56 +0200)
Also extracted the reduced Autoloading setup for the test suites. This
way I can avoid duplicating code when defining the Autoload.php setup
I use for running single test suites.

framework/Kolab_Config/test/Horde/Kolab/Config/Autoload.php
framework/Test/lib/Horde/Test/AllTests.php
framework/Test/lib/Horde/Test/Autoload.php [new file with mode: 0644]
framework/Test/package.xml

index 0e91eaa..ca9ba59 100644 (file)
  * @link       http://pear.horde.org/index.php?package=Kolab_Config
  */
 
-if (!spl_autoload_functions()) {
-    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);'
-        )
-    );
-}
+require_once 'Horde/Test/Autoload.php';
 
 /** Catch strict standards */
 error_reporting(E_ALL | E_STRICT);
index a365744..6e6a819 100644 (file)
@@ -67,18 +67,7 @@ class Horde_Test_AllTests
         // Set up autoload
         $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);'
-                    . '$err_mask = E_ALL ^ E_WARNING;'
-                    . '$oldErrorReporting = error_reporting($err_mask);'
-                    . 'include "$filename.php";'
-                    . 'error_reporting($oldErrorReporting);'
-                )
-            );
-        }
+        require_once 'Horde/Test/Autoload.php';
 
         $suite = new PHPUnit_Framework_TestSuite('Horde Framework - ' . self::$_package);
         $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/');
diff --git a/framework/Test/lib/Horde/Test/Autoload.php b/framework/Test/lib/Horde/Test/Autoload.php
new file mode 100644 (file)
index 0000000..d4a6cc1
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Reduced Horde Autoloader for test suites.
+ *
+ * @author     Jan Schneider <jan@horde.org>
+ * @author     Gunnar Wrobel <wrobel@pardus.de>
+ * @license    http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @category   Horde
+ * @package    Horde_Test
+ * @subpackage UnitTests
+ */
+$autoloaders = spl_autoload_functions();
+if (!empty($autoloaders)) {
+    /**
+     * Ignore autoloaders which are incapable of loading Horde
+     * classes (e.g. PHPUnit >= 3.5.0)
+     */
+    $autoloaders = array_diff($autoloaders, array('phpunit_autoload'));
+}
+if (empty($autoloaders)) {
+    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);'
+        )
+    );
+}
index d60d5d4..ee7fcff 100644 (file)
@@ -30,6 +30,7 @@
     <dir name="Horde">
      <dir name="Test">
       <file name="AllTests.php" role="php" />
+      <file name="Autoload.php" role="php" />
       <file name="Case.php" role="php" />
       <file name="Functional.php" role="php" />
      </dir> <!-- /lib/Horde/Test -->
@@ -54,6 +55,7 @@
  <phprelease>
   <filelist>
    <install as="Horde/Test/AllTests.php" name="lib/Horde/Test/AllTests.php" />
+   <install as="Horde/Test/Autoload.php" name="lib/Horde/Test/Autoload.php" />
    <install as="Horde/Test/Case.php" name="lib/Horde/Test/Case.php" />
    <install as="Horde/Test/Functional.php" name="lib/Horde/Test/Functional.php" />
   </filelist>