Skip to content

Commit

Permalink
Make test bootstrap.php files consistent.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronweeden committed Oct 20, 2023
1 parent d228ff0 commit 58ba43b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 18 deletions.
42 changes: 34 additions & 8 deletions tests/integration_tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
56 changes: 46 additions & 10 deletions tests/unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 58ba43b

Please sign in to comment.