From 4edaec11cfcfae661561ea8c28256221f02f5924 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 24 Aug 2010 10:07:50 +0200 Subject: [PATCH] Add a fix to ignore the autoloading of the newer PHPUnit (>= 3.5.0, currently RC). 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. --- .../test/Horde/Kolab/Config/Autoload.php | 13 +-------- framework/Test/lib/Horde/Test/AllTests.php | 13 +-------- framework/Test/lib/Horde/Test/Autoload.php | 31 ++++++++++++++++++++++ framework/Test/package.xml | 2 ++ 4 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 framework/Test/lib/Horde/Test/Autoload.php diff --git a/framework/Kolab_Config/test/Horde/Kolab/Config/Autoload.php b/framework/Kolab_Config/test/Horde/Kolab/Config/Autoload.php index 0e91eaa6b..ca9ba5921 100644 --- a/framework/Kolab_Config/test/Horde/Kolab/Config/Autoload.php +++ b/framework/Kolab_Config/test/Horde/Kolab/Config/Autoload.php @@ -17,18 +17,7 @@ * @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); diff --git a/framework/Test/lib/Horde/Test/AllTests.php b/framework/Test/lib/Horde/Test/AllTests.php index a36574430..6e6a8199b 100644 --- a/framework/Test/lib/Horde/Test/AllTests.php +++ b/framework/Test/lib/Horde/Test/AllTests.php @@ -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 index 000000000..d4a6cc1a1 --- /dev/null +++ b/framework/Test/lib/Horde/Test/Autoload.php @@ -0,0 +1,31 @@ + + * @author Gunnar Wrobel + * @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);' + ) + ); +} diff --git a/framework/Test/package.xml b/framework/Test/package.xml index d60d5d433..ee7fcff06 100644 --- a/framework/Test/package.xml +++ b/framework/Test/package.xml @@ -30,6 +30,7 @@ + @@ -54,6 +55,7 @@ + -- 2.11.0