From 6a56b593fe2461d874c6cf60789a93dd0014791d Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 13 Dec 2009 12:09:46 -0500 Subject: [PATCH] There's logic in this test suite for dealing with whether or not adapters are available that isn't in Horde_Test_AllTests. --- framework/Db/test/Horde/Db/AllTests.php | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/framework/Db/test/Horde/Db/AllTests.php b/framework/Db/test/Horde/Db/AllTests.php index f5b6ef4e2..059a27f82 100644 --- a/framework/Db/test/Horde/Db/AllTests.php +++ b/framework/Db/test/Horde/Db/AllTests.php @@ -34,6 +34,52 @@ date_default_timezone_set('America/New_York'); */ class Horde_Db_AllTests extends Horde_Test_AllTests { + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + // Catch strict standards + error_reporting(E_ALL | E_STRICT); + + // Ensure a default timezone is set. + date_default_timezone_set('America/New_York'); + + // Set up autoload + set_include_path(dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path()); + if (!spl_autoload_functions()) { + spl_autoload_register(create_function('$class', '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class); @include_once "$filename.php";')); + } + + // Build the suite + $suite = new PHPUnit_Framework_TestSuite('Horde Framework - Horde_Db'); + + $basedir = dirname(__FILE__); + $baseregexp = preg_quote($basedir . DIRECTORY_SEPARATOR, '/'); + + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir)) as $file) { + if (!$file->isFile()) { + continue; + } + + $filename = $file->getFilename(); + $pathname = $file->getPathname(); + $class = str_replace(DIRECTORY_SEPARATOR, '_', + preg_replace("/^$baseregexp(.*)\.php/", '\\1', $pathname)); + + if (preg_match('/Suite.php$/', $filename)) { + require $pathname; + $suite->addTestSuite('Horde_Db_' . $class); + } elseif (strpos($class, 'Adapter_') === false && preg_match('/Test.php$/', $filename)) { + require $pathname; + $suite->addTestSuite('Horde_Db_' . $class); + } + } + + return $suite; + } } if (PHPUnit_MAIN_METHOD == 'Horde_Db_AllTests::main') { -- 2.11.0