From 72284545a63f843e5e7d1f99d36aad177e68d1b4 Mon Sep 17 00:00:00 2001 From: mwjames Date: Thu, 16 Oct 2014 03:08:43 +0900 Subject: [PATCH] Improve bootstrap test autoloader This should enable us to run tests on [0] again successfully [0] https://travis-ci.org/mwjames/SemanticBundle/jobs/38066206 Change-Id: Ia438f2c61c1ed5d4cd202337d321241399b53506 --- tests/bootstrap.php | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 00c9404..ff1cfa2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,39 +4,16 @@ die( 'Not an entry point' ); } -if ( !defined( 'MEDIAWIKI' ) ) { - die( 'MediaWiki is not available for the test environment' ); +if ( is_readable( $path = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php' ) ) { + print( "\nUsing SemanticMediaWiki ...\n" ); +} else { + die( 'The SemanticMediaWiki test autoloader is not available' ); } -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 = require $path; - $autoLoader->addPsr4( 'SG\\Tests\\', __DIR__ . '/phpunit' ); +$autoloader->addPsr4( 'SG\\Tests\\', __DIR__ . '/phpunit' ); - $autoLoader->addClassMap( array( - 'SG\Maintenance\RebuildGlossaryCache' => __DIR__ . '/../maintenance/rebuildGlossaryCache.php', - ) ); - - return true; -} - -if ( !runTestAutoLoader() ) { - die( 'The required test autoloader was not accessible' ); -} +$autoloader->addClassMap( array( + 'SG\Maintenance\RebuildGlossaryCache' => __DIR__ . '/../maintenance/rebuildGlossaryCache.php', +) );