From cceb6809e743f032a991ef9487a194af0a81f173 Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Mon, 24 Jun 2024 14:20:33 +0200 Subject: [PATCH] :white_check_mark: Fix CI --- .../src/BaseTestCase/ItopTestCase.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php index 7b7d40725..8573a81d9 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php @@ -169,6 +169,27 @@ abstract class ItopTestCase extends TestCase return $sAppRootPath . '/'; } + private static function GetFirstDirUpContainingFile(string $sSearchPath, string $sFileToFindGlobPattern): ?string + { + for ($iDepth = 0; $iDepth < 8; $iDepth++) { + $aGlobFiles = glob($sSearchPath . '/' . $sFileToFindGlobPattern); + if (is_array($aGlobFiles) && (count($aGlobFiles) > 0)) { + return $sSearchPath . '/'; + } + $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 null; + } + + /** * Overload this method to require necessary files through {@see \Combodo\iTop\Test\UnitTest\ItopTestCase::RequireOnceItopFile()} *