diff --git a/sources/Composer/iTopComposer.php b/sources/Composer/iTopComposer.php index c759d9ed0..0f5f0e77a 100644 --- a/sources/Composer/iTopComposer.php +++ b/sources/Composer/iTopComposer.php @@ -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); } /** diff --git a/test/application/composer/iTopComposerTest.php b/test/application/composer/iTopComposerTest.php index 2d7ef86ee..159714618 100644 --- a/test/application/composer/iTopComposerTest.php +++ b/test/application/composer/iTopComposerTest.php @@ -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) + ); } - - }