There's logic in this test suite for dealing with whether or not adapters are
authorChuck Hagenbuch <chuck@horde.org>
Sun, 13 Dec 2009 17:09:46 +0000 (12:09 -0500)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 13 Dec 2009 17:09:46 +0000 (12:09 -0500)
available that isn't in Horde_Test_AllTests.

framework/Db/test/Horde/Db/AllTests.php

index f5b6ef4..059a27f 100644 (file)
@@ -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') {