Skip to content

Commit

Permalink
Allow the PHPUnit PHAR to be loaded as a library
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 30, 2014
1 parent 8ded926 commit f220079
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions build/phar-autoload.php.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env php
<?php
if ($GLOBALS['_SERVER']['SCRIPT_NAME'] != '-') {
$phar = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
if (__FILE__ == $GLOBALS['_SERVER']['SCRIPT_NAME']) {
$phar = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
$execute = true;
} else {
$files = get_included_files();
$phar = $files[0];
$files = get_included_files();
$phar = $files[0];
$execute = false;
}

define('__PHPUNIT_PHAR__', str_replace(DIRECTORY_SEPARATOR, '/', $phar));
Expand All @@ -31,12 +33,12 @@ spl_autoload_register(

Phar::mapPhar('___PHAR___');

if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == '--manifest') {
print file_get_contents(__PHPUNIT_PHAR_ROOT__ . '/manifest.txt');
exit;
}
if ($execute) {
if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == '--manifest') {
print file_get_contents(__PHPUNIT_PHAR_ROOT__ . '/manifest.txt');
exit;
}

if ($GLOBALS['_SERVER']['SCRIPT_NAME'] != '-') {
PHPUnit_TextUI_Command::main();
}

Expand Down

0 comments on commit f220079

Please sign in to comment.