Skip to content

Commit

Permalink
Improve bootstrap test autoloader
Browse files Browse the repository at this point in the history
This should enable us to run tests on [0] again successfully

[0] https://travis-ci.org/mwjames/SemanticBundle/jobs/38066206

Change-Id: Ia438f2c61c1ed5d4cd202337d321241399b53506
  • Loading branch information
mwjames committed Oct 15, 2014
1 parent 8580571 commit 7228454
Showing 1 changed file with 9 additions and 32 deletions.
41 changes: 9 additions & 32 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
) );

0 comments on commit 7228454

Please sign in to comment.