diff --git a/application/utils.inc.php b/application/utils.inc.php index 6217f1afb..c083e7f10 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2089,18 +2089,35 @@ class utils } /** - * @return string eg : '2_7_0' + * @return string eg : '2_7_0' ITOP_VERSION is '2.7.1-dev' */ public static function GetItopVersionWikiSyntax() { - $sVersionShort = self::GetItopVersionShort(); - return str_replace('.', '_', $sVersionShort); + $sMinorVersion = self::GetItopMinorVersion(); + return str_replace('.', '_', $sMinorVersion).'_0'; + } + + /** + * @return string eg 2.7 if ITOP_VERSION is '2.7.0-dev' + * @throws \Exception + */ + public static function GetItopMinorVersion() + { + $sPatchVersion = self::GetItopPatchVersion(); + $aExplodedVersion = explode('.', $sPatchVersion); + + if (empty($aExplodedVersion[0]) || empty($aExplodedVersion[1])) + { + throw new Exception('iTop version is wrongfully configured!'); + } + + return sprintf('%d.%d', $aExplodedVersion[0], $aExplodedVersion[1]); } /** * @return string eg '2.7.0' if ITOP_VERSION is '2.7.0-dev' */ - public static function GetItopVersionShort() + public static function GetItopPatchVersion() { $aExplodedVersion = explode('-', ITOP_VERSION); return $aExplodedVersion[0]; diff --git a/test/releaseChecklist/iTopModulesPhpVersionChecklistTest.php b/test/releaseChecklist/iTopModulesPhpVersionChecklistTest.php index 793677660..71c480e4a 100644 --- a/test/releaseChecklist/iTopModulesPhpVersionChecklistTest.php +++ b/test/releaseChecklist/iTopModulesPhpVersionChecklistTest.php @@ -45,9 +45,9 @@ class iTopModulesPhpVersionChecklistTest extends ItopTestCase * Verify if the datamodel.*.xml files refer to the current itop version * This is part of the checklist tests. * - * @dataProvider DatamodelItopXmlVersionProvider + * @dataProvider iTopModulesPhpVersionProvider */ - public function testDatamodelItopXmlVersion($sExpectedVersion, $sPhpFile) + public function testiTopModulesPhpVersion($sExpectedVersion, $sPhpFile) { $sModulePath = realpath($sPhpFile); @@ -65,17 +65,30 @@ class iTopModulesPhpVersionChecklistTest extends ItopTestCase $this->assertSame($sExpectedVersion, $matches[1], "$sPhpFile file refer does not refer to current itop version ($matches[1] instead of expected $sExpectedVersion)"); } - public function DatamodelItopXmlVersionProvider() + public function iTopModulesPhpVersionProvider() { parent::setUp(); require_once APPROOT.'core/config.class.inc.php'; require_once APPROOT.'application/utils.inc.php'; - $sPath = APPROOT.'datamodels/2.x/*/module.*.php'; + if (is_dir(APPROOT.'datamodels/2.x')) + { + $DatamodelsPath = APPROOT.'datamodels/2.x'; + } + elseif (is_dir(APPROOT.'datamodels/1.x')) + { + $DatamodelsPath = APPROOT.'datamodels/1.x'; + } + else + { + throw new \Exception('Cannot local the datamodels directory'); + } + + $sPath = $DatamodelsPath.'/*/module.*.php'; $aPhpFiles = glob($sPath); - $sExpectedVersion = \utils::GetItopVersionShort(); + $sExpectedVersion = \utils::GetItopPatchVersion(); $aTestCases = array(); foreach ($aPhpFiles as $sPhpFile) diff --git a/test/releaseChecklist/iTopModulesXmlVersionChecklistTest.php b/test/releaseChecklist/iTopModulesXmlVersionChecklistTest.php index b863f3327..658bac1af 100644 --- a/test/releaseChecklist/iTopModulesXmlVersionChecklistTest.php +++ b/test/releaseChecklist/iTopModulesXmlVersionChecklistTest.php @@ -70,7 +70,7 @@ class iTopModulesXmlVersionChecklistTest extends ItopTestCase $sPath = APPROOT.'datamodels/2.x/*/datamodel.*.xml'; $aXmlFiles = glob($sPath); - $sItopVersionShort = \utils::GetItopVersionShort(); + $sItopVersionShort = \utils::GetItopPatchVersion(); $aItopVersion = explode('.', $sItopVersionShort); $sExpectedXmlVersion = ($aItopVersion[0] - 1).'.'.($aItopVersion[1]); // eg: 2.7.0-dev become 1.7