From 25791a1d18ad3f347822a6a7bba39a4f9a468987 Mon Sep 17 00:00:00 2001 From: bruno DA SILVA Date: Thu, 16 Jul 2020 16:45:06 +0200 Subject: [PATCH] 3052 - Check community modules XML version against latest version --- .../iTopModulesXmlVersionChecklistTest.php | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 test/release-checklist/iTopModulesXmlVersionChecklistTest.php diff --git a/test/release-checklist/iTopModulesXmlVersionChecklistTest.php b/test/release-checklist/iTopModulesXmlVersionChecklistTest.php new file mode 100644 index 0000000000..a6be36626a --- /dev/null +++ b/test/release-checklist/iTopModulesXmlVersionChecklistTest.php @@ -0,0 +1,89 @@ + + * + */ + +namespace Combodo\iTop\Test\UnitTest\ReleaseChecklist; + +use Combodo\iTop\Test\UnitTest\ItopTestCase; +use DOMDocument; +use iTopDesignFormat; + + +/** + * Class iTopDesignFormatChecklistTest + * + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + * @backupGlobals disabled + * + * @covers iTopDesignFormat + * + * @package Combodo\iTop\Test\UnitTest\Setup + */ +class iTopModulesXmlVersionChecklistTest extends ItopTestCase +{ + + + /** + * Verify if the datamodel.*.xml files refer to the current itop version + * This is part of the checklist tests. + * + * @dataProvider DatamodelItopXmlVersionProvider + */ + public function testDatamodelItopXmlVersion($sExpectedXmlVersion, $sXmlFile) + { + $sFileContent = file_get_contents($sXmlFile); + + preg_match( + '//', + $sFileContent, + $matches + ); + + $this->assertSame($sExpectedXmlVersion, $matches[1]); + } + + public function DatamodelItopXmlVersionProvider() + { + parent::setUp(); + + require_once APPROOT.'core/config.class.inc.php'; + require_once APPROOT.'application/utils.inc.php'; + + $sPath = APPROOT.'datamodels/2.x/*/datamodel.*.xml'; + $aXmlFiles = glob($sPath); + + $sItopVersionShort = \utils::GetItopVersionShort(); + $aItopVersion = explode('.', $sItopVersionShort); + $sExpectedXmlVersion = ($aItopVersion[0] - 1).'.'.($aItopVersion[1]); // eg: 2.7.0-dev become 1.7 + + $aTestCases = array(); + foreach ($aXmlFiles as $sXmlFile) + { + $aTestCases[$sXmlFile] = array( + 'sExpectedXmlVersion' => $sExpectedXmlVersion, + 'sXmlFile' => $sXmlFile, + ); + } + + return $aTestCases; + } + +}