From 68e1addcf3287581e5e02e77577639e2d87d78fb Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Thu, 3 Dec 2009 13:07:38 +0100 Subject: [PATCH] One test suite to rule them all. --- .../test/Horde/Date/Parser/AllTests.php | 50 ++++++---------------- .../Icalendar/test/Horde/Icalendar/AllTests.php | 50 ++++++---------------- framework/Rdo/test/Horde/Rdo/AllTests.php | 45 ++++++------------- 3 files changed, 42 insertions(+), 103 deletions(-) diff --git a/framework/Date_Parser/test/Horde/Date/Parser/AllTests.php b/framework/Date_Parser/test/Horde/Date/Parser/AllTests.php index acc75c74d..9493307ed 100644 --- a/framework/Date_Parser/test/Horde/Date/Parser/AllTests.php +++ b/framework/Date_Parser/test/Horde/Date/Parser/AllTests.php @@ -7,48 +7,26 @@ * @license http://opensource.org/licenses/bsd-license.php */ +/** + * Define the main method + */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Horde_Date_Parser_AllTests::main'); } -require_once 'PHPUnit/Framework/TestSuite.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -class Horde_Date_Parser_AllTests { - - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - set_include_path(dirname(__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 - Horde_Date_Parser'); - - $basedir = dirname(__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('Horde_Date_Parser_' . $class); - } - } - - return $suite; - } +/** + * Prepare the test setup. + */ +require_once 'Horde/Test/AllTests.php'; +/** + * @package Horde_Date_Parser + * @subpackage UnitTests + */ +class Horde_Date_Parser_AllTests extends Horde_Test_AllTests +{ } if (PHPUnit_MAIN_METHOD == 'Horde_Date_Parser_AllTests::main') { - Horde_Date_Parser_AllTests::main(); + Horde_Date_Parser_AllTests::main('Horde_Date_Parser', __FILE__); } diff --git a/framework/Icalendar/test/Horde/Icalendar/AllTests.php b/framework/Icalendar/test/Horde/Icalendar/AllTests.php index 16e35fbd2..335c39130 100644 --- a/framework/Icalendar/test/Horde/Icalendar/AllTests.php +++ b/framework/Icalendar/test/Horde/Icalendar/AllTests.php @@ -7,48 +7,26 @@ * @license http://www.fsf.org/copyleft/lgpl.html */ +/** + * Define the main method + */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Horde_Icalendar_AllTests::main'); } -require_once 'PHPUnit/Framework/TestSuite.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -class Horde_Icalendar_AllTests { - - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - set_include_path(dirname(__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 - Horde_Icalendar'); - - $basedir = dirname(__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('Horde_Icalendar_' . $class); - } - } - - return $suite; - } +/** + * Prepare the test setup. + */ +require_once 'Horde/Test/AllTests.php'; +/** + * @package Horde_Icalendar + * @subpackage UnitTests + */ +class Horde_Icalendar_AllTests extends Horde_Test_AllTests +{ } if (PHPUnit_MAIN_METHOD == 'Horde_Icalendar_AllTests::main') { - Horde_Icalendar_AllTests::main(); + Horde_Icalendar_AllTests::main('Horde_Icalendar', __FILE__); } diff --git a/framework/Rdo/test/Horde/Rdo/AllTests.php b/framework/Rdo/test/Horde/Rdo/AllTests.php index 85f505ae0..db00103cd 100644 --- a/framework/Rdo/test/Horde/Rdo/AllTests.php +++ b/framework/Rdo/test/Horde/Rdo/AllTests.php @@ -4,43 +4,26 @@ * @subpackage UnitTests */ +/** + * Define the main method + */ if (!defined('PHPUnit_MAIN_METHOD')) { define('PHPUnit_MAIN_METHOD', 'Horde_Rdo_AllTests::main'); } -require_once 'PHPUnit/Framework/TestSuite.php'; -require_once 'PHPUnit/TextUI/TestRunner.php'; - -class Horde_Rdo_AllTests { - - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('Horde Framework - Horde_Rdo'); - - $basedir = dirname(__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('Horde_Rdo_' . $class); - } - } - - return $suite; - } +/** + * Prepare the test setup. + */ +require_once 'Horde/Test/AllTests.php'; +/** + * @package Horde_Rdo + * @subpackage UnitTests + */ +class Horde_Rdo_AllTests extends Horde_Test_AllTests +{ } if (PHPUnit_MAIN_METHOD == 'Horde_Rdo_AllTests::main') { - Horde_Rdo_AllTests::main(); + Horde_Rdo_AllTests::main('Horde_Rdo', __FILE__); } -- 2.11.0