Skip to content

Commit

Permalink
Use realpath() on SCRIPT_NAME as Composer invokes PHPUnit through a s…
Browse files Browse the repository at this point in the history
…ymlinked script.
  • Loading branch information
sebastianbergmann committed Oct 6, 2012
1 parent 39461cf commit 4c5545c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions PHPUnit/Util/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ class PHPUnit_Util_Filter
public static function getFilteredStacktrace(Exception $e, $asString = TRUE)
{
$prefix = FALSE;
$script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);

if (substr($GLOBALS['_SERVER']['SCRIPT_NAME'], -5) == '.phar') {
$prefix = 'phar://' . $GLOBALS['_SERVER']['SCRIPT_NAME'] . '/';
if (substr($script, -5) == '.phar') {
$prefix = 'phar://' . $script . '/';
}

if (!defined('PHPUNIT_TESTSUITE')) {
Expand Down Expand Up @@ -107,7 +108,7 @@ public static function getFilteredStacktrace(Exception $e, $asString = TRUE)
if (isset($frame['file']) && is_file($frame['file']) &&
!isset($blacklist[$frame['file']]) &&
strpos($frame['file'], $prefix) !== 0 &&
$frame['file'] !== $GLOBALS['_SERVER']['SCRIPT_NAME']) {
$frame['file'] !== $script) {
if ($asString === TRUE) {
$filteredStacktrace .= sprintf(
"%s:%s\n",
Expand Down
5 changes: 3 additions & 2 deletions PHPUnit/Util/GlobalState.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ public static function getIncludedFilesAsString()
$files = get_included_files();
$prefix = FALSE;
$result = '';
$script = realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);

if (substr($GLOBALS['_SERVER']['SCRIPT_NAME'], -5) == '.phar') {
$prefix = 'phar://' . $GLOBALS['_SERVER']['SCRIPT_NAME'] . '/';
if (substr($script, -5) == '.phar') {
$prefix = 'phar://' . $script . '/';
}

for ($i = count($files) - 1; $i > 0; $i--) {
Expand Down

0 comments on commit 4c5545c

Please sign in to comment.