diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/Bootstrap/tests/bootstrap.php |
first commit
Diffstat (limited to 'www/wiki/extensions/Bootstrap/tests/bootstrap.php')
-rw-r--r-- | www/wiki/extensions/Bootstrap/tests/bootstrap.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/www/wiki/extensions/Bootstrap/tests/bootstrap.php b/www/wiki/extensions/Bootstrap/tests/bootstrap.php new file mode 100644 index 00000000..cff461f0 --- /dev/null +++ b/www/wiki/extensions/Bootstrap/tests/bootstrap.php @@ -0,0 +1,38 @@ +<?php + +if ( php_sapi_name() !== 'cli' ) { + die( 'Not an entry point' ); +} + +if ( !defined( 'MEDIAWIKI' ) ) { + die( 'MediaWiki is not available for the test environment' ); +} + +function registerAutoloaderPath( $identifier, $path ) { + print( "\nUsing the {$identifier} vendor autoloader ...\n\n" ); + return require $path; +} + +function runTestAutoLoader() { + + $mwVendorPath = __DIR__ . '/../../../vendor/autoload.php'; + $localVendorPath = __DIR__ . '/../vendor/autoload.php'; + + if ( is_readable( $localVendorPath ) ) { + $autoLoader = registerAutoloaderPath( 'local', $localVendorPath ); + } elseif ( is_readable( $mwVendorPath ) ) { + $autoLoader = registerAutoloaderPath( 'MediaWiki', $mwVendorPath ); + } + + if ( !$autoLoader instanceof \Composer\Autoload\ClassLoader ) { + return false; + } + + $autoLoader->addPsr4( 'Bootstrap\\Tests\\', __DIR__ . '/phpunit' ); + + return true; +} + +if ( !runTestAutoLoader() ) { + die( 'The required test autoloader was not accessible' ); +} |