mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°4771 Fix lib test dir detection
Thanks to @Molkobain and @Hipska for their review in dfaa9733
This commit is contained in:
@@ -27,7 +27,7 @@ use RecursiveIteratorIterator;
|
||||
|
||||
class iTopComposer
|
||||
{
|
||||
const TEST_DIR_REGEXP = '/^[tT]ests?$/';
|
||||
const TEST_DIR_REGEXP = '/^tests?$/i';
|
||||
|
||||
/**
|
||||
* @return array List of all subdirs of /lib that are {@see IsTestDir}.
|
||||
@@ -61,10 +61,17 @@ class iTopComposer
|
||||
|
||||
return $aAllTestDirs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $sDirName
|
||||
*
|
||||
* @return false|int as {@see \preg_match()}
|
||||
* @uses self::TEST_DIR_REGEXP
|
||||
* @uses \preg_match()
|
||||
*/
|
||||
public static function IsTestDir($sDirName)
|
||||
{
|
||||
return preg_match(self::TEST_DIR_REGEXP, $sDirName);
|
||||
return preg_match(static::TEST_DIR_REGEXP, $sDirName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,35 @@ class iTopComposerTest extends ItopTestCase
|
||||
clearstatcache();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider IsTestDirProvider
|
||||
* @return void
|
||||
*/
|
||||
public function testIsTestDir($sDirName, $bIsTest)
|
||||
{
|
||||
$isTestDir = iTopComposer::IsTestDir($sDirName);
|
||||
$this->assertInternalType('int', $isTestDir);
|
||||
if (true === $bIsTest) {
|
||||
$this->assertTrue(($isTestDir > 0));
|
||||
} else {
|
||||
$this->assertSame(0, $isTestDir);
|
||||
}
|
||||
}
|
||||
|
||||
public function IsTestDirProvider()
|
||||
{
|
||||
return [
|
||||
'test' => ['test', true],
|
||||
'Test' => ['Test', true],
|
||||
'tests' => ['tests', true],
|
||||
'Tests' => ['Tests', true],
|
||||
'testaa' => ['testaa', false],
|
||||
'Testaa' => ['Testaa', false],
|
||||
'testsaa' => ['testsaa', false],
|
||||
'Testsaa' => ['Testsaa', false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testListAllTestDir()
|
||||
{
|
||||
$oiTopComposer = new iTopComposer();
|
||||
@@ -40,9 +69,9 @@ class iTopComposerTest extends ItopTestCase
|
||||
|
||||
$this->assertTrue(is_array($aDirs));
|
||||
|
||||
foreach ($aDirs as $sDir)
|
||||
{
|
||||
$this->assertRegExp('#[tT]ests?/?$#', $sDir);
|
||||
foreach ($aDirs as $sDir) {
|
||||
$sDirName = basename($sDir);
|
||||
$this->assertRegExp(iTopComposer::TEST_DIR_REGEXP, $sDirName, "Directory not matching test dir : $sDir");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user