N°6228 - Refactor after review

This commit is contained in:
Eric Espie
2023-11-20 09:22:41 +01:00
parent f72d8f4955
commit 8e0d6d1f00
11 changed files with 302 additions and 516 deletions

View File

@@ -33,6 +33,29 @@ class MetaModelTest extends ItopDataTestCase
parent::tearDown();
}
/**
* @covers MetaModel::GetObjectByName
* @return void
* @throws \CoreException
*/
public function testGetFinalClassName()
{
// Standalone classes
$this->assertEquals('Organization', MetaModel::GetFinalClassName('Organization', 1), 'Should work with standalone classes');
$this->assertEquals('SynchroDataSource', MetaModel::GetFinalClassName('SynchroDataSource', 1), 'Should work with standalone classes');
// 2 levels hierarchy
$this->assertEquals('Person', MetaModel::GetFinalClassName('Contact', 1));
$this->assertEquals('Person', MetaModel::GetFinalClassName('Person', 1));
// multi-level hierarchy
$oServer1 = MetaModel::GetObjectByName('Server', 'Server1');
$sServer1Id = $oServer1->GetKey();
foreach (MetaModel::EnumParentClasses('Server',ENUM_PARENT_CLASSES_ALL) as $sClass) {
$this->assertEquals('Server', MetaModel::GetFinalClassName($sClass, $sServer1Id), 'Should return Server for all the classes in the hierarchy');
}
}
/**
* @group itopRequestMgmt
* @covers MetaModel::ApplyParams()