diff --git a/setup/itopdesignformat.class.inc.php b/setup/itopdesignformat.class.inc.php index d4cdb8874..bd0783081 100644 --- a/setup/itopdesignformat.class.inc.php +++ b/setup/itopdesignformat.class.inc.php @@ -1,5 +1,5 @@ +define('ITOP_DESIGN_LATEST_VERSION', '1.7'); // iTop >= 2.7.0 + /** * Utility to upgrade the format of a given XML datamodel to the latest version * The datamodel is supplied as a loaded DOMDocument and modified in-place. - * + * + * To test migration methods check {@link \Combodo\iTop\Test\UnitTest\Setup\TestForITopDesignFormatClass} + * * Usage: * * $oDocument = new DOMDocument(); @@ -34,9 +38,6 @@ * echo "Error, failed to upgrade the format, reason(s):\n".implode("\n", $oFormat->GetErrors()); * } */ - -define('ITOP_DESIGN_LATEST_VERSION', '1.7'); // iTop >= 2.7.0 - class iTopDesignFormat { protected static $aVersions = array( diff --git a/test/setup/iTopDesignFormat/1.7_to_1.6.expected.xml b/test/setup/iTopDesignFormat/1.7_to_1.6.expected.xml new file mode 100644 index 000000000..280019cad --- /dev/null +++ b/test/setup/iTopDesignFormat/1.7_to_1.6.expected.xml @@ -0,0 +1,15 @@ + + + + + 100 + WelcomeMenu + $$http://fr.wikipedia.org/ + + + 100 + WelcomeMenu + $$http://fr.wikipedia.org/ + + + diff --git a/test/setup/iTopDesignFormat/1.7_to_1.6.input.xml b/test/setup/iTopDesignFormat/1.7_to_1.6.input.xml new file mode 100644 index 000000000..ec041ae93 --- /dev/null +++ b/test/setup/iTopDesignFormat/1.7_to_1.6.input.xml @@ -0,0 +1,16 @@ + + + + + 100 + WelcomeMenu + $$http://fr.wikipedia.org/ + true + + + 100 + WelcomeMenu + $$http://fr.wikipedia.org/ + + + diff --git a/test/setup/iTopDesignFormat/iTopDesignFormatTest.php b/test/setup/iTopDesignFormat/iTopDesignFormatTest.php new file mode 100644 index 000000000..cabfbba24 --- /dev/null +++ b/test/setup/iTopDesignFormat/iTopDesignFormatTest.php @@ -0,0 +1,73 @@ +GetFileContent($sInputXmlFileName); + $sExpectedXml = $this->GetFileContent($sExpectedXmlFileName); + + $oInputDocument = new DOMDocument(); + libxml_clear_errors(); + $oInputDocument->preserveWhiteSpace = false; + $oInputDocument->loadXML($sInputXml); + $oInputDocument->formatOutput = true; + $oDesignFormat = new iTopDesignFormat($oInputDocument); + $oDesignFormat->Convert($sTargetVersion); + + $sConvertedXml = $oInputDocument->saveXML(); + + $this->assertEquals($sExpectedXml, $sConvertedXml); + } + + private function GetFileContent($sFileName) + { + $sCurrentPath = __DIR__; + + return file_get_contents($sCurrentPath.DIRECTORY_SEPARATOR.$sFileName.'.xml'); + } + + public function testMigrationMethodProvider() + { + return array( + '1.7 to 1.6' => array('1.6', '1.7_to_1.6.input', '1.7_to_1.6.expected'), + ); + } +} \ No newline at end of file