mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 14:08:46 +02:00
💚 fix test to make conversion functions exist for any one found in datamodels files (itop pro version)
This commit is contained in:
@@ -59,6 +59,8 @@ class TestForITopDesignFormatClass extends ItopTestCase
|
||||
//make sure there is only one found
|
||||
$this->assertTrue(is_array($aDatamodelCurrentVersions));
|
||||
|
||||
$sFirstVersion = array_keys(iTopDesignFormat::$aVersions)[0];
|
||||
$sLatestVersion = array_keys(iTopDesignFormat::$aVersions)[count(iTopDesignFormat::$aVersions)-1];
|
||||
foreach ($aDatamodelCurrentVersions as $sCurrentVersion)
|
||||
{
|
||||
try{
|
||||
@@ -67,16 +69,36 @@ class TestForITopDesignFormatClass extends ItopTestCase
|
||||
$aCurrentVersionInfo = iTopDesignFormat::$aVersions[$sCurrentVersion];
|
||||
$this->CheckCondition(is_array($aCurrentVersionInfo), "Wrong $sCurrentVersion config in iTopDesignFormat.");
|
||||
$this->CheckCondition(array_key_exists('previous', $aCurrentVersionInfo), "Missing previous for $sCurrentVersion config in iTopDesignFormat.");
|
||||
$this->TestDefinedFunction($aCurrentVersionInfo, 'go_to_next', $sCurrentVersion, ($sCurrentVersion=== $sLatestVersion));
|
||||
$this->TestDefinedFunction($aCurrentVersionInfo, 'go_to_previous', $sCurrentVersion, ($sCurrentVersion==='1.0'));
|
||||
|
||||
//check we have migration function from N-1 version to current one
|
||||
$sPreviousVersion = $aCurrentVersionInfo['previous'];
|
||||
$this->CheckCondition(array_key_exists($sPreviousVersion, iTopDesignFormat::$aVersions), "Missing $sPreviousVersion config in iTopDesignFormat.");
|
||||
$aPreviousVersionInfo = iTopDesignFormat::$aVersions[$sPreviousVersion];
|
||||
$this->CheckCondition(is_array($aPreviousVersionInfo), "wrong $sPreviousVersion config in iTopDesignFormat.");
|
||||
$this->CheckCondition(array_key_exists('previous', $aPreviousVersionInfo), "Missing previous for $sPreviousVersion config in iTopDesignFormat.");
|
||||
$this->TestDefinedFunction($aPreviousVersionInfo, 'go_to_previous', $sPreviousVersion);
|
||||
$this->TestDefinedFunction($aPreviousVersionInfo, 'go_to_next', $sPreviousVersion, ($sCurrentVersion==='1.7'));
|
||||
if (($sCurrentVersion!=='1.0')) {
|
||||
$sPreviousVersion = $aCurrentVersionInfo['previous'];
|
||||
$this->CheckCondition(array_key_exists($sPreviousVersion, iTopDesignFormat::$aVersions),
|
||||
"$sCurrentVersion: Missing $sPreviousVersion config in iTopDesignFormat.");
|
||||
$aPreviousVersionInfo = iTopDesignFormat::$aVersions[$sPreviousVersion];
|
||||
$this->CheckCondition(is_array($aPreviousVersionInfo),
|
||||
"$sCurrentVersion: wrong $sPreviousVersion config in iTopDesignFormat.");
|
||||
$this->CheckCondition(array_key_exists('previous', $aPreviousVersionInfo),
|
||||
"$sCurrentVersion: Missing previous for $sPreviousVersion config in iTopDesignFormat.");
|
||||
$this->TestDefinedFunction($aPreviousVersionInfo, 'go_to_previous', $sPreviousVersion, ($sPreviousVersion === '1.0'));
|
||||
$this->TestDefinedFunction($aPreviousVersionInfo, 'go_to_next', $sPreviousVersion, ($sPreviousVersion === $sLatestVersion));
|
||||
}
|
||||
|
||||
//check we have migration function from current version to next one
|
||||
if (($sCurrentVersion!== $sLatestVersion)) {
|
||||
$sNextVersion = $aCurrentVersionInfo['next'];
|
||||
$this->CheckCondition(array_key_exists($sNextVersion, iTopDesignFormat::$aVersions),
|
||||
"$sCurrentVersion: Missing $sNextVersion config in iTopDesignFormat.");
|
||||
$aNextVersionInfo = iTopDesignFormat::$aVersions[$sNextVersion];
|
||||
$this->CheckCondition(is_array($aNextVersionInfo),
|
||||
"$sCurrentVersion: wrong $sNextVersion config in iTopDesignFormat.");
|
||||
$this->CheckCondition(array_key_exists('previous', $aNextVersionInfo),
|
||||
"$sCurrentVersion: Missing previous for $sNextVersion config in iTopDesignFormat.");
|
||||
$this->TestDefinedFunction($aNextVersionInfo, 'go_to_previous', $sNextVersion, ($sNextVersion === '1.0'));
|
||||
$this->TestDefinedFunction($aNextVersionInfo, 'go_to_next', $sNextVersion, ($sNextVersion === $sLatestVersion));
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
@@ -108,7 +130,7 @@ class TestForITopDesignFormatClass extends ItopTestCase
|
||||
{
|
||||
$sInfo = json_encode($aCurrentVersionInfo, true);
|
||||
$this->CheckCondition(array_key_exists($sFunctionKey, $aCurrentVersionInfo), "Missing $sFunctionKey in $sVersion config in iTopDesignFormat: " . $sInfo);
|
||||
echo $aCurrentVersionInfo[$sFunctionKey].'\n';
|
||||
//echo $aCurrentVersionInfo[$sFunctionKey].'\n';
|
||||
if ($bNullFunction === false)
|
||||
{
|
||||
$oReflectionClass = new \ReflectionClass(iTopDesignFormat::class);
|
||||
|
||||
Reference in New Issue
Block a user