diff --git a/tests/integration_tests/bootstrap.php b/tests/integration_tests/bootstrap.php index 7e09b61..9536daa 100644 --- a/tests/integration_tests/bootstrap.php +++ b/tests/integration_tests/bootstrap.php @@ -2,19 +2,45 @@ $dir = __DIR__; -// Autoloader for main framework test classes. +// Autoloader for test classes. spl_autoload_register( function ($className) use ($dir) { - $classPath - = $dir - . '/../../../xdmod/open_xdmod/modules/xdmod/integration_tests/lib/' + // Replace the IntegrationTests namespace prefix with the path to the + // integration tests lib directory. + $classPath = preg_replace( + '/IntegrationTests\\\\?/', + "$dir/lib/", + $className + ); + // Replace namespace separators with directory separators. + $classPath = str_replace('\\', '/', $classPath) . '.php'; + if (is_readable($classPath)) { + return require_once $classPath; + } + // Replace the IntegrationTests namespace prefix with the path to + // the main integration tests lib directory. + $classPath = preg_replace( + '/IntegrationTests\\\\?/', + "$dir/../../../xdmod/tests/integration/lib/", + $className + ); + // Replace namespace separators with directory separators. + $classPath = str_replace('\\', '/', $classPath) . '.php'; + if (is_readable($classPath)) { + return require_once $classPath; + } + // Autoload the AppKernels module classes + $classPath = ( + "$dir/../../classes/" . str_replace('\\', '/', $className) - . '.php'; - + . '.php' + ); if (is_readable($classPath)) { return require_once $classPath; - } else { - return false; } + return false; } ); + +// Autoloader for XDMoD classes. +require_once __DIR__ . '/../../../xdmod/configuration/linker.php'; diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index 0ff6fc4..3192711 100644 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -2,23 +2,59 @@ $dir = __DIR__; -// Autoloader for main framework test classes. +// Autoloader for test classes. spl_autoload_register( function ($className) use ($dir) { - $classPath - = $dir - . '/../../../xdmod/open_xdmod/modules/xdmod/integration_tests/lib/' + // Replace the UnitTests namespace prefix with the path to the unit + // tests lib directory. + $classPath = preg_replace( + '/UnitTests\\\\?/', + "$dir/lib/", + $className + ); + // Replace the IntegrationTests namespace prefix with the path to the + // integration tests lib directory. + $classPath = preg_replace( + '/IntegrationTests\\\\?/', + "$dir/../integration_tests/lib/", + $classPath + ); + // Replace namespace separators with directory separators. + $classPath = str_replace('\\', '/', $classPath) . '.php'; + if (is_readable($classPath)) { + return require_once $classPath; + } + // Replace the UnitTests namespace prefix with the path to the main + // unit tests lib directory. + $classPath = preg_replace( + '/UnitTests\\\\?/', + "$dir/../../../xdmod/tests/unit/lib/", + $className + ); + // Replace the IntegrationTests namespace prefix with the path to + // the main integration tests lib directory. + $classPath = preg_replace( + '/IntegrationTests\\\\?/', + "$dir/../../../xdmod/tests/integration/lib/", + $classPath + ); + // Replace namespace separators with directory separators. + $classPath = str_replace('\\', '/', $classPath) . '.php'; + if (is_readable($classPath)) { + return require_once $classPath; + } + // Autoload the AppKernels module classes + $classPath = ( + "$dir/../../classes/" . str_replace('\\', '/', $className) - . '.php'; - + . '.php' + ); if (is_readable($classPath)) { return require_once $classPath; - } else { - return false; } + return false; } ); // Autoloader for XDMoD classes. -// require_once __DIR__ . '/../../configuration/linker.php'; -require_once '/usr/share/xdmod/configuration/linker.php'; +require_once __DIR__ . '/../../../xdmod/configuration/linker.php';