From ea8509db1f100607e742b88563ef107b73fb2aae Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 7 Sep 2023 14:47:36 +0200 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20N=C2=B06709=20Use=20?= =?UTF-8?q?=20ItopTestCase::RequireOnceCurrentModuleFile=20in=20GetAppRoot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/BaseTestCase/ItopTestCase.php | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) 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 . '/'; } /**