Reintegrate validation tests to ease iTop release management from develop

- N°3053 - Check XML conversion methods
     - N°3059 - Automatically set the documentation URLs
     - N°3052 - Check community modules XML version against latest version
     - N°3054 - Check community modules version against major version
     - N°3062 - setup.css file integrity test
     - N°3060 - Check consistency between the list of modules and installation.xml
     - N°3061 - Automatically check the installation.xml consistency
     - N°3268 Add test to check dictionary files: make sure that the Dict::Add declarations match the file name
This commit is contained in:
odain
2020-09-29 08:57:57 +02:00
parent d86e904e18
commit 20ce42b24b
9 changed files with 302 additions and 122 deletions

View File

@@ -32,48 +32,57 @@ use iTopDesignFormat;
*/
class iTopModulesXmlVersionIntegrationTest extends ItopTestCase
{
protected function setUp()
{
parent::setUp();
require_once APPROOT.'setup/itopdesignformat.class.inc.php';
}
/**
* Verify if the datamodel.*.xml files refer to the current itop version
* Verify if the datamodel.*.xml files refer to the latest version of the design
* This is an integration test
*
* @group skipPostBuild
*
* @dataProvider DatamodelItopXmlVersionProvider
*/
public function testDatamodelItopXmlVersion($sExpectedXmlVersion, $sXmlFile)
public function testDatamodelItopXmlVersion($sXmlFile)
{
$sFileContent = file_get_contents($sXmlFile);
$oOriginalXml = new DOMDocument();
$oOriginalXml->load($sXmlFile);
preg_match(
'/<itop_design .* version="([^"]+)">/',
$sFileContent,
$matches
);
$oTransformedXml = new DOMDocument();
$oTransformedXml->load($sXmlFile);
$oFormat = new iTopDesignFormat($oTransformedXml);
$this->assertSame($sExpectedXmlVersion, $matches[1], "$sXmlFile file refer does not refer to current itop version ($matches[1] instead of expected $sExpectedXmlVersion)");
if ($oFormat->Convert())
{
// Compare the original and new format
$sExpectedXmlVersion = ITOP_DESIGN_LATEST_VERSION;
$this->assertSame($oTransformedXml->saveXML(), $oOriginalXml->saveXML(), "Datamodel file $sXmlFile:2 not in the latest format ($sExpectedXmlVersion)");
}
else
{
$this->fail("Failed to convert $sXmlFile into the latest format");
}
}
public function DatamodelItopXmlVersionProvider()
{
parent::setUp();
require_once APPROOT.'core/config.class.inc.php';
require_once APPROOT.'application/utils.inc.php';
static::setUp();
$sPath = APPROOT.'datamodels/2.x/*/datamodel.*.xml';
$aXmlFiles = glob($sPath);
$sItopVersionShort = \utils::GetItopPatchVersion();
$aItopVersion = explode('.', $sItopVersionShort);
$sExpectedXmlVersion = ($aItopVersion[0] - 1).'.'.($aItopVersion[1]); // eg: 2.7.0-dev become 1.7
$aXmlFiles[] = APPROOT.'core/datamodel.core.xml';
$aXmlFiles[] = APPROOT.'application/datamodel.application.xml';
$aTestCases = array();
foreach ($aXmlFiles as $sXmlFile)
{
$aTestCases[$sXmlFile] = array(
'sExpectedXmlVersion' => $sExpectedXmlVersion,
'sXmlFile' => $sXmlFile,
);
}