summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Bootstrap/tests/bootstrap.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/Bootstrap/tests/bootstrap.php')
-rw-r--r--www/wiki/extensions/Bootstrap/tests/bootstrap.php38
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' );
+}