first commit
This commit is contained in:
46
plugins/simplesaml/lib/tests/_autoload_modules.php
Normal file
46
plugins/simplesaml/lib/tests/_autoload_modules.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file registers an autoloader for test classes used by SimpleSAMLphp modules unit tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Autoload function for SimpleSAMLphp modules test classes following PSR-4.
|
||||
* Module test classes have namespaces like SimpleSAML\Test\Module\<moduleName>\Auth\Process
|
||||
*
|
||||
* @param string $className Name of the class.
|
||||
* @return void
|
||||
*/
|
||||
function sspmodTestClassAutoloadPSR4(string $className): void
|
||||
{
|
||||
$elements = explode('\\', $className);
|
||||
if ($elements[0] === '') {
|
||||
// class name starting with /, ignore
|
||||
array_shift($elements);
|
||||
}
|
||||
if (count($elements) < 5) {
|
||||
return; // it can't be a module test class
|
||||
}
|
||||
if (array_shift($elements) !== 'SimpleSAML') {
|
||||
return; // the first element is not "SimpleSAML"
|
||||
}
|
||||
if (array_shift($elements) !== 'Test') {
|
||||
return; // the second element is not "test"
|
||||
}
|
||||
if (array_shift($elements) !== 'Module') {
|
||||
return; // the third element is not "module"
|
||||
}
|
||||
|
||||
// this is a SimpleSAMLphp module test class following PSR-4
|
||||
$module = array_shift($elements);
|
||||
$moduleTestDir = __DIR__ . '/modules/' . $module;
|
||||
$file = $moduleTestDir . '/src/' . implode('/', $elements) . '.php';
|
||||
|
||||
if (file_exists($file)) {
|
||||
require_once($file);
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('sspmodTestClassAutoloadPSR4');
|
7
plugins/simplesaml/lib/tests/config/defined_config.php
Normal file
7
plugins/simplesaml/lib/tests/config/defined_config.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
$config = [
|
||||
'defined' => 'config',
|
||||
];
|
7
plugins/simplesaml/lib/tests/config/returned_config.php
Normal file
7
plugins/simplesaml/lib/tests/config/returned_config.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'returned' => 'config',
|
||||
];
|
Reference in New Issue
Block a user