diff --git a/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php b/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php
index 5f38692af..5a3184204 100644
--- a/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php
+++ b/tests/php-unit-tests/unitary-tests/setup/ModelFactoryTest.php
@@ -1423,4 +1423,332 @@ XML
],
];
}
+
+ /**
+ * @test
+ * @dataProvider LoadDeltaProvider
+ * @covers ModelFactory::LoadDelta
+ *
+ * @param $sInitialXML
+ * @param $sDeltaXML
+ * @param $sExpectedXML
+ *
+ * @return void
+ * @throws \Exception
+ */
+ public function LoadDeltaTest($sInitialXML, $sDeltaXML, $sExpectedXML)
+ {
+ $oFactory = $this->MakeVanillaModelFactory($sInitialXML);
+ $oFactoryDocument = $this->GetNonPublicProperty($oFactory, 'oDOMDocument');
+
+ // Load the delta
+ $oDocument = new MFDocument();
+ $oDocument->loadXML($sDeltaXML);
+ /* @var MFElement $oDeltaRoot */
+ $oDeltaRoot = $oDocument->firstChild;
+ try {
+ $oFactory->LoadDelta($oDeltaRoot, $oFactoryDocument);
+ }
+ catch (\Exception $e) {
+ $this->assertNull($sExpectedXML, 'LoadDelta() should not have failed with exception: '.$e->getMessage());
+
+ return;
+ }
+ $this->AssertEqualModels($sExpectedXML, $oFactory, 'LoadDelta() did not produce the expected result');
+ }
+
+ public function LoadDeltaProvider()
+ {
+ return [
+ 'Creating classes' => [
+ 'sInitialXML' => '
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ cmdbAbstractObject
+
+
+ Contact
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+ Contact
+
+
+
+
+',
+ ],
+ 'Error merging classes' => [
+ 'sInitialXML' => '
+
+
+
+ cmdbAbstractObject
+
+ Contact
+
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ titi
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+ Contact
+ titi
+
+
+
+
+',
+ ],
+ 'Error loading module - could not be deleted' => [
+ 'sInitialXML' => '
+
+
+
+ cmdbAbstractObject
+
+ Contact
+
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ cmdbAbstractObject
+
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+
+ Contact
+
+
+
+
+',
+ ],
+ 'redefine class with sub-class' => [
+ 'sInitialXML' => '
+
+
+
+ cmdbAbstractObject
+
+ Contact
+
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ cmdbAbstractObject
+
+
+ Contact
+
+
+ Contact
+
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+
+ Contact
+
+
+ Contact
+
+
+ Contact
+
+
+
+
+',
+ ],
+ 'force class with sub-class' => [
+ 'sInitialXML' => '
+
+
+
+ cmdbAbstractObject
+
+ Contact
+
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ cmdbAbstractObject
+
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+
+ Contact
+
+
+
+
+',
+ ],
+ 'Class added with hierarchy' => [
+ 'sInitialXML' => '
+
+
+
+ cmdbAbstractObject
+
+
+ cmdbAbstractObject
+
+ Licence
+
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ FunctionalCI
+
+ ConfigElement
+
+ Key
+
+
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+ FunctionalCI
+
+ ConfigElement
+
+ Key
+
+
+
+
+
+ cmdbAbstractObject
+
+ Licence
+
+
+
+
+',
+ ],
+ 'Class added with hierarchy needs redefine' => [
+ 'sInitialXML' => '
+
+
+
+ cmdbAbstractObject
+
+
+ cmdbAbstractObject
+
+ Licence
+
+
+
+
+',
+ 'sDeltaXML' => '
+
+
+ FunctionalCI
+
+ ConfigElement
+
+ Key
+
+
+
+
+ Key
+
+
+',
+ 'sExpectedXML' => '
+
+
+
+ cmdbAbstractObject
+
+ FunctionalCI
+
+ ConfigElement
+
+ Key
+
+
+ Key
+
+
+
+
+
+
+',
+ ],
+
+ ];
+ }
}