Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions HttpPHPUnit/Main/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ public static function create($file)

public static function getBasePath()
{
$dir = realpath(__DIR__ . '/..');
$documentRoot = realpath($_SERVER['DOCUMENT_ROOT']);
if (!$documentRoot) throw new Exception;
$documentRoot = rtrim($documentRoot, DIRECTORY_SEPARATOR);
$tmp = $documentRoot . DIRECTORY_SEPARATOR;
if ($documentRoot != $dir AND strncmp($dir, $tmp, strlen($tmp)) !== 0) throw new Exception;
return str_replace('\\', '/', substr($dir, strlen($documentRoot)));
$dir = str_replace('\\', '/', realpath(__DIR__ . '/..')); // <== even Windows will have /
$self = $_SERVER['PHP_SELF']; // e.g. /Ticketon/tests/index.php or /Clevis/Ticketon/tests/index.php
$pathToHttpPHPUnitRoot = substr($self, 0, -9); // e.g. /Ticketon/tests/ or /Clevis/Ticketon/tests/
$positionOfHttpPHPUnitRoot = strrpos($dir, $pathToHttpPHPUnitRoot);

return substr($dir, $positionOfHttpPHPUnitRoot); // e.g. /Ticketon/tests/libs/HttpPHPUnit or /Clevis/Ticketon/tests/libs/HttpPHPUnit
}

}