From 0dc4a4f5410a85d14154e911d4a545c669b064ac Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 9 Apr 2014 10:42:06 +0200 Subject: [PATCH] Refactor php unittest bootstrapping refs #4639 --- test/php/TestInit.php | 67 ------------------------------------------ test/php/bootstrap.php | 51 ++++++++++++++++++++++++++++++++ test/php/phpunit.xml | 2 +- 3 files changed, 52 insertions(+), 68 deletions(-) delete mode 100644 test/php/TestInit.php create mode 100644 test/php/bootstrap.php diff --git a/test/php/TestInit.php b/test/php/TestInit.php deleted file mode 100644 index c8a901256..000000000 --- a/test/php/TestInit.php +++ /dev/null @@ -1,67 +0,0 @@ -registerNamespace('Icinga', $libaryPath . '/Icinga'); - $loader->registerNamespace('Icinga\\Form', $applicationPath . '/forms'); - - - $modules = scandir($modulePath); - - foreach ($modules as $module) { - if ($module === '.' || $module === '..') { - continue; - } - - $baseNs = 'Icinga\\Module\\' . ucfirst($module); - $moduleLibraryPath = $modulePath . '/' . $module . '/library/' . ucfirst($module); - - if (is_dir($moduleLibraryPath)) { - $loader->registerNamespace($baseNs, $moduleLibraryPath); - } - - $moduleTestPath = $modulePath . '/' . $module . '/test'; - if (is_dir($moduleTestPath)) { - $testNs = $baseNs .= '\\Test'; - $loader->registerNamespace($testNs, $moduleTestPath); - } - - $moduleFormPath = $modulePath . '/' . $module . '/application/forms'; - if (is_dir($moduleFormPath)) { - $formNs = $baseNs .= '\\Form'; - $loader->registerNamespace($formNs, $moduleFormPath); - } - } - - $loader->register(); - - require_once 'Zend/Loader/Autoloader.php'; - \Zend_Loader_Autoloader::getInstance(); - - Icinga\Application\Config::$configDir = $configPath; - } -} - -TestInit::bootstrap(); diff --git a/test/php/bootstrap.php b/test/php/bootstrap.php new file mode 100644 index 000000000..413052450 --- /dev/null +++ b/test/php/bootstrap.php @@ -0,0 +1,51 @@ +registerNamespace('Icinga', $libraryPath . '/Icinga'); +$loader->registerNamespace('Icinga\\Form', $applicationPath . '/forms'); + +$modules = scandir($modulePath); +foreach ($modules as $module) { + if ($module === '.' || $module === '..') { + continue; + } + + $moduleNamespace = 'Icinga\\Module\\' . ucfirst($module); + $moduleLibraryPath = $modulePath . '/' . $module . '/library/' . ucfirst($module); + + if (is_dir($moduleLibraryPath)) { + $loader->registerNamespace($moduleNamespace, $moduleLibraryPath); + } + + $moduleTestPath = $modulePath . '/' . $module . '/test'; + if (is_dir($moduleTestPath)) { + $loader->registerNamespace($moduleNamespace . '\\Test', $moduleTestPath); + } + + $moduleFormPath = $modulePath . '/' . $module . '/application/forms'; + if (is_dir($moduleFormPath)) { + $loader->registerNamespace($moduleNamespace . '\\Form', $moduleFormPath); + } +} + +$loader->register(); + +require_once 'Zend/Loader/Autoloader.php'; +\Zend_Loader_Autoloader::getInstance(); + +Icinga\Application\Config::$configDir = $configPath; diff --git a/test/php/phpunit.xml b/test/php/phpunit.xml index 268addce7..6ae11aebb 100644 --- a/test/php/phpunit.xml +++ b/test/php/phpunit.xml @@ -1,5 +1,5 @@ - +