diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php index 29385464a..fc8cc58c3 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php @@ -107,22 +107,10 @@ abstract class ItopTestCase extends TestCase if (defined('APPROOT')) { return APPROOT; } - $sSearchPath = __DIR__; - for ($iDepth = 0; $iDepth < 8; $iDepth++) { - if (file_exists($sSearchPath.'/approot.inc.php')) { - break; - } - $iOffsetSep = strrpos($sSearchPath, '/'); - if ($iOffsetSep === false) { - $iOffsetSep = strrpos($sSearchPath, '\\'); - if ($iOffsetSep === false) { - // Do not throw an exception here as PHPUnit will not show it clearly when determing the list of test to perform - return 'Could not find the approot file in '.$sSearchPath; - } - } - $sSearchPath = substr($sSearchPath, 0, $iOffsetSep); - } - return $sSearchPath.'/'; + + $sAppRootPath = static::GetFirstDirUpContainingFile(__DIR__, 'approot.inc.php'); + + return $sAppRootPath . '/'; } /**