Merge pull request #357 from bantu/tests-composer-autoloader-php5

[php5] Use composer autoloader in test bootstrap.

* bantu/tests-composer-autoloader-php5:
  PHP 5.3+: Replace custom autoloader with composer autoloader.
This commit is contained in:
Andreas Fischer 2014-06-01 22:01:31 +02:00
commit 6dbcdb8174

View File

@ -7,37 +7,13 @@
date_default_timezone_set('UTC');
// Set up include path accordingly. This is especially required because some
// class files of phpseclib require() other dependencies.
set_include_path(implode(PATH_SEPARATOR, array(
dirname(__FILE__) . '/../phpseclib/',
dirname(__FILE__) . '/',
get_include_path(),
)));
function phpseclib_is_includable($suffix)
{
foreach (explode(PATH_SEPARATOR, get_include_path()) as $prefix) {
$ds = substr($prefix, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
$file = $prefix . $ds . $suffix;
if (file_exists($file)) {
return true;
}
}
return false;
$loader_path = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($loader_path)) {
echo "Dependencies must be installed using composer:\n\n";
echo "php composer.phar install --dev\n\n";
echo "See http://getcomposer.org for help with installing composer\n";
exit(1);
}
function phpseclib_autoload($class)
{
$file = str_replace('_', '/', $class) . '.php';
if (phpseclib_is_includable($file)) {
// @codingStandardsIgnoreStart
require $file;
// @codingStandardsIgnoreEnd
}
}
spl_autoload_register('phpseclib_autoload');
$loader = include $loader_path;
$loader->add('', __DIR__);