. * * @author mwjames * @since 1.0 * @ingroup Skins */ 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; } /** * @return string */ function getDirectory() { $directory = $GLOBALS[ 'argv' ][ 0 ]; if ( $directory[ 0 ] !== DIRECTORY_SEPARATOR ) { $directory = $_SERVER[ 'PWD' ] . DIRECTORY_SEPARATOR . $directory; } $directory = dirname( $directory ); return $directory; } function runTestAutoLoader( $autoLoader = null ) { $directory = getDirectory(); $mwVendorPath = $directory . '/../../vendor/autoload.php'; $localVendorPath = $directory . '/../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; } return true; } if ( !runTestAutoLoader() ) { die( 'Required test class loader was not accessible' ); }