mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-28 06:34:14 +01:00
N°3990 - Compiler: Set "_delta" flag on moved node if no ancestors has one
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Combodo\iTop\Test\UnitTest\Setup;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use iTopDesignFormat;
|
||||
|
||||
|
||||
@@ -34,8 +35,7 @@ class TestForITopDesignFormatClass extends ItopTestCase
|
||||
* @dataProvider ConvertProvider
|
||||
*
|
||||
* @param string $sTargetVersion
|
||||
* @param string $sInputXmlFileName example "1.7_to_1.6.input"
|
||||
* @param string $sExpectedXmlFileName example "1.7_to_1.6.expected"
|
||||
* @param string $sInputXmlFileName Example "1.7_to_1.6"
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
@@ -66,6 +66,63 @@ class TestForITopDesignFormatClass extends ItopTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers iTopDesignFormat::MoveNode
|
||||
* @dataProvider MoveNodeProvider
|
||||
*
|
||||
* @param string $sXmlFileName Example "from_deleted_to_not-in-definition"
|
||||
*/
|
||||
public function testMoveNode(string $sXmlFileName)
|
||||
{
|
||||
$sSamplesRelDirPath = 'MoveNode-samples/';
|
||||
$sInputXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.input');
|
||||
$sExpectedXml = $this->GetFileContent($sSamplesRelDirPath.$sXmlFileName.'.expected');
|
||||
|
||||
// Prepare document
|
||||
$oInputDocument = new DOMDocument();
|
||||
libxml_clear_errors();
|
||||
$oInputDocument->preserveWhiteSpace = false;
|
||||
$oInputDocument->loadXML($sInputXml);
|
||||
$oInputDocument->formatOutput = true;
|
||||
$oDesignFormat = new iTopDesignFormat($oInputDocument);
|
||||
|
||||
$oXPath = new DOMXPath($oInputDocument);
|
||||
|
||||
// Move nodes
|
||||
// Note: We could have pass the XPaths in the provider, but as for now they are the same for all cases, it's easier to read like this. Feel free to change it in the future if necessary.
|
||||
$oFNode = $oXPath->query("//f")->item(0);
|
||||
// - Self node
|
||||
$oCNodeList = $oXPath->query("//c");
|
||||
if ($oCNodeList->length > 0) {
|
||||
$oCNode = $oCNodeList->item(0);
|
||||
$this->InvokeNonPublicMethod('iTopDesignFormat', 'MoveNode', $oDesignFormat, [$oCNode, $oFNode]);
|
||||
}
|
||||
// - In parent node
|
||||
$oENodeList = $oXPath->query("//e");
|
||||
if ($oENodeList->length > 0) {
|
||||
$oENode = $oENodeList->item(0);
|
||||
$this->InvokeNonPublicMethod('iTopDesignFormat', 'MoveNode', $oDesignFormat, [$oENode, $oFNode]);
|
||||
}
|
||||
|
||||
$sConvertedXml = $oInputDocument->saveXML();
|
||||
$this->assertEquals($sExpectedXml, $sConvertedXml);
|
||||
}
|
||||
|
||||
public function MoveNodeProvider()
|
||||
{
|
||||
return array(
|
||||
'From deleted to deleted' => array('from_deleted_to_deleted'),
|
||||
'From deleted to in definition' => array('from_deleted_to_in-definition'),
|
||||
'From deleted to not in definition' => array('from_deleted_to_not-in-definition'),
|
||||
'From in definition to deleted' => array('from_in-definition_to_deleted'),
|
||||
'From in definition to in definition' => array('from_in-definition_to_in-definition'),
|
||||
'From in definition to not in definition' => array('from_in-definition_to_not-in-definition'),
|
||||
'From not in definition to deleted' => array('from_not-in-definition_to_deleted'),
|
||||
'From not in definition to in definition' => array('from_not-in-definition_to_in-definition'),
|
||||
'From not in definition to not in definition' => array('from_not-in-definition_to_not-in-definition'),
|
||||
);
|
||||
}
|
||||
|
||||
private function GetFileContent($sFileName)
|
||||
{
|
||||
$sCurrentPath = __DIR__;
|
||||
|
||||
Reference in New Issue
Block a user