public static function getTestMagentoRootFromEnvironment($varname, $basename)
{
$root = getenv($varname);
if (empty($root) && strlen($basename)) {
$stopfile = getcwd() . '/' . $basename;
if (is_readable($stopfile) && ($buffer = rtrim(file_get_contents($stopfile)))) {
$root = $buffer;
}
}
if (empty($root)) {
return;
}
# directory test
if (!is_dir($root)) {
throw new RuntimeException(sprintf("%s path '%s' is not a directory", $varname, $root));
}
# resolve root to realpath to be independent to current working directory
$rootRealpath = realpath($root);
if (false === $rootRealpath) {
throw new RuntimeException(sprintf("Failed to resolve %s path '%s' with realpath()", $varname, $root));
}
return $rootRealpath;
}
<?php use N98\Magento\Command\TestCase; $base = TestCase::getTestMagentoRootFromEnvironment('N98_MAGERUN_TEST_MAGENTO_ROOT', '.n98-magerun'); if (false === $base) { unset($base); return; } @session_start(); $loader = (require __DIR__ . '/../vendor/autoload.php'); /* @var $loader \Composer\Autoload\ClassLoader */ $loader->setUseIncludePath(true); $paths = array($base . '/app/code/local', $base . '/app/code/community', $base . '/app/code/core', $base . '/lib'); set_include_path(implode(PATH_SEPARATOR, $paths) . PATH_SEPARATOR . get_include_path()); unset($paths, $base);