diff --git a/application/utils.inc.php b/application/utils.inc.php index 90fef1059..273345039 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2247,38 +2247,18 @@ class utils /** * @return string eg : '2_7_0' iTop core version is '2.7.1-dev' + * @throws \ApplicationException if constant value is invalid + * @uses ITOP_CORE_VERSION */ public static function GetItopVersionWikiSyntax() { - $sMinorVersion = self::GetItopMinorVersion(); - return str_replace('.', '_', $sMinorVersion).'_0'; - } + $aExplodedVersion = explode('.', ITOP_CORE_VERSION); - /** - * @return string eg 2.7 if iTop core 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!'); + if (empty($aExplodedVersion[0]) || empty($aExplodedVersion[1])) { + throw new ApplicationException('iTop version is wrongfully configured!'); } - return sprintf('%d.%d', $aExplodedVersion[0], $aExplodedVersion[1]); - } - - /** - * @return string eg '2.7.0' if iTop core version is '2.7.0-dev' - * @uses ITOP_CORE_VERSION - */ - public static function GetItopPatchVersion() - { - $aExplodedVersion = explode('-', ITOP_CORE_VERSION); - return $aExplodedVersion[0]; + return "{$aExplodedVersion[0]}_{$aExplodedVersion[1]}_0"; } /** diff --git a/approot.inc.php b/approot.inc.php index e56fe770e..dae2341e2 100644 --- a/approot.inc.php +++ b/approot.inc.php @@ -11,7 +11,8 @@ define('APPCONF', APPROOT.'conf/'); * When releasing, both constants should be updated : see `.make/release/update-versions.php` for that ! * * @since 2.7.7 3.0.1 3.1.0 N°4714 constant creation - * @used-by utils::GetItopPatchVersion + * @used-by utils::GetItopVersionWikiSyntax() + * @used-by iTopModulesPhpVersionIntegrationTest */ define('ITOP_CORE_VERSION', '2.7.7'); diff --git a/test/integration/iTopModulesPhpVersionChecklistTest.php b/test/integration/iTopModulesPhpVersionChecklistTest.php index c99008644..421699618 100644 --- a/test/integration/iTopModulesPhpVersionChecklistTest.php +++ b/test/integration/iTopModulesPhpVersionChecklistTest.php @@ -35,6 +35,8 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase * @group skipPostBuild * * @dataProvider iTopModulesPhpVersionProvider + * + * @since 2.7.7 3.0.1 3.1.0 N°4714 uses new {@link ITOP_CORE_VERSION} constant */ public function testiTopModulesPhpVersion($sExpectedVersion, $sPhpFile) { @@ -51,9 +53,8 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase $matches ); - $this->assertRegExp("#$sExpectedVersion#", $matches[1], - " $sPhpFile:2 file refer does not refer to current itop version ($sModuleName/$matches[1] does not match regexp $sModuleName/$sExpectedVersion)"); - + $this->assertSame($sExpectedVersion, $matches[1], + 'Module desc file does not contain the same version as the core: '.$sPhpFile); } public function iTopModulesPhpVersionProvider() @@ -74,7 +75,7 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase $sPath = $DatamodelsPath.'/*/module.*.php'; $aPhpFiles = glob($sPath); - $sExpectedVersion = \utils::GetItopMinorVersion().'\.\d+'; // ie: 2.7\.\d+ (and yes, the 1st dot should be escaped, but, hey, it is good enough as it, ans less complex to read) + $sExpectedVersion = ITOP_CORE_VERSION; $aTestCases = array(); foreach ($aPhpFiles as $sPhpFile) {