N°4771 improve iTopComposerTest

- debug testListDeniedTestDir not working well on Windows
- update error message for testAllDirCovered
This commit is contained in:
Pierre Goiffon
2022-02-10 12:21:40 +01:00
parent 2e45b20fc4
commit dfaa973359
2 changed files with 17 additions and 7 deletions

View File

@@ -27,6 +27,8 @@ use RecursiveIteratorIterator;
class iTopComposer
{
const TEST_DIR_REGEXP = '/^[tT]ests?$/';
/**
* @return array List of all subdirs of /lib that are {@see IsTestDir}.
* Warning : each path contains slashes (meaning on Windows you'll get eg `C:/Dev/wamp64/www/itop-27/lib/goaop/framework/tests`)
@@ -60,9 +62,9 @@ class iTopComposer
return $aAllTestDirs;
}
private function IsTestDir($sDirName)
public static function IsTestDir($sDirName)
{
return preg_match('/^[tT]ests?$/', $sDirName);
return preg_match(self::TEST_DIR_REGEXP, $sDirName);
}
/**

View File

@@ -54,10 +54,16 @@ class iTopComposerTest extends ItopTestCase
$this->assertTrue(is_array($aDirs));
$aDeniedDirWrongFormat = [];
foreach ($aDirs as $sDir)
{
$this->assertRegExp('#[tT]ests?/?$#', $sDir);
if (false === iTopComposer::IsTestDir($sDir)) {
$aDeniedDirWrongFormat[] = $sDir;
}
}
$this->assertEmpty($aDeniedDirWrongFormat,
'There are elements in \Combodo\iTop\Composer\iTopComposer::ListDeniedTestDir that are not test dirs :'.var_export($aDeniedDirWrongFormat, true));
}
public function testListAllowedTestDir()
@@ -100,9 +106,11 @@ class iTopComposerTest extends ItopTestCase
$aMissing = array_diff($aExistingDirs, $aAllowedAndDeniedDirs);
$aExtra = array_diff($aAllowedAndDeniedDirs, $aExistingDirs);
$this->assertEmpty($aMissing, "The iTop instance running this test has matching directories That must be either in the allowed or in the denied list:".var_export($aMissing, true));
$this->assertEmpty(
$aMissing,
'Test dirs exists in /lib !'."\n"
.' They must be declared either in the allowed or denied list in '.iTopComposer::class." (see N°2651).\n"
.' List of dirs:'."\n".var_export($aMissing, true)
);
}
}