From: Jan Schneider Date: Thu, 3 Dec 2009 12:15:43 +0000 (+0100) Subject: Missed to add the base test suite. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d416227a2cf5a103e5e6e016a43cec9ee56340f8;p=horde.git Missed to add the base test suite. --- diff --git a/framework/Test/lib/Horde/Test/AllTests.php b/framework/Test/lib/Horde/Test/AllTests.php new file mode 100644 index 000000000..3372fc1a7 --- /dev/null +++ b/framework/Test/lib/Horde/Test/AllTests.php @@ -0,0 +1,78 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Horde_Test + * @subpackage UnitTests + */ + +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Horde_Test_AllTests::main'); +} + +require_once 'PHPUnit/Framework.php'; +require_once 'PHPUnit/TextUI/TestRunner.php'; + +/** + * @package Horde_Test + * @subpackage UnitTests + */ +class Horde_Test_AllTests +{ + /** @todo: Use protected properties and LSB with PHP 5.3. */ + private static $_file = __FILE__; + private static $_package = 'Horde_Test'; + + /** + * Main entry point for running the suite. + */ + public static function main($package = null, $file = null) + { + if ($package) { + self::$_package = $package; + } + if ($file) { + self::$_file = $file; + } + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + /** + * Collect the unit tests of this directory into a new suite. + * + * @return PHPUnit_Framework_TestSuite The test suite. + */ + public static function suite() + { + // Catch strict standards + error_reporting(E_ALL | E_STRICT); + + // Set up autoload + set_include_path(dirname(self::$_file) . '/../../../lib' . PATH_SEPARATOR . get_include_path()); + if (!spl_autoload_functions()) { + spl_autoload_register(create_function('$class', '$filename = str_replace(array(\'\\\\\', \'_\'), \'/\', $class); include "$filename.php";')); + } + + $suite = new PHPUnit_Framework_TestSuite('Horde Framework - ' . self::$_package); + + $basedir = dirname(self::$_file); + $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/'); + + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir)) as $file) { + if ($file->isFile() && preg_match('/Test.php$/', $file->getFilename())) { + $pathname = $file->getPathname(); + require $pathname; + + $class = str_replace(DIRECTORY_SEPARATOR, '_', + preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname)); + $suite->addTestSuite(self::$_package . '_' . $class); + } + } + + return $suite; + } + +}