Enhance Service locator

This commit is contained in:
Eric Espie
2026-01-27 11:54:05 +01:00
parent 390b5c0bc3
commit bfa7a209d6
43 changed files with 338 additions and 210 deletions

View File

@@ -28,8 +28,6 @@ class DashboardSerializerTest extends ItopDataTestCase
*/
public function testSerializeXML($normalizedValue, string $sXMLContent)
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
$oDOMDocument = new PropertyTypeDesign();
$oDOMDocument->preserveWhiteSpace = false;
$oDOMDocument->formatOutput = true;

View File

@@ -24,8 +24,6 @@ class FormsCompilerTest extends ItopDataTestCase
*/
public function testCompileFormFromXML(string $sXMLContent, string $sExpectedPHP)
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
$sProducedPHP = PropertyTypeCompiler::GetInstance()->CompileFormFromXML($sXMLContent);
$this->AssertPHPCodeIsValid($sProducedPHP);
@@ -862,8 +860,6 @@ XML,
public function testCompileFormForIconSelection()
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
$sXMLContent = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<property_type id="basic_test_for_icon" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">
@@ -899,8 +895,6 @@ PHP;
public function testCompileFormForClassSelection()
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
$sXMLContent = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<property_type id="basic_test_for_class" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Combodo-PropertyType" xsi:noNamespaceSchemaLocation = "https://www.combodo.com/itop-schema/3.3">

View File

@@ -24,8 +24,6 @@ class XMLSerializerTest extends ItopDataTestCase
*/
public function testSerializeXML($normalizedValue, string $sPropertyTypeXML, string $sXMLContent)
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
$oDOMDocument = new PropertyTypeDesign();
$oDOMDocument->preserveWhiteSpace = false;
$oDOMDocument->formatOutput = true;
@@ -369,8 +367,6 @@ XML,
*/
public function testUnserializeXML($normalizedValue, string $sPropertyTypeXML, string $sXMLContent)
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', new ModelReflectionRuntime());
$oDoc = new PropertyTypeDesign();
$oDoc->loadXML($sXMLContent);
/** @var \Combodo\iTop\DesignElement $oRoot */

View File

@@ -17,7 +17,7 @@ class DataModelDependantCacheTest extends ItopTestCase
$this->sCacheRootDir = self::CreateTmpdir();
$this->oCacheService = DataModelDependantCache::GetInstance();
$this->oCacheService = static::GetService('DataModelDependantCache');
$this->oCacheService->SetStorageRootDir($this->sCacheRootDir);
}

View File

@@ -19,7 +19,7 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
parent::setUp();
$this->oInterfaceDiscovery = InterfaceDiscovery::GetInstance();
$this->sCacheRootDir = self::CreateTmpdir();
$this->oCacheService = DataModelDependantCache::GetInstance();
$this->oCacheService = static::GetService('DataModelDependantCache');
$this->oCacheService->SetStorageRootDir($this->sCacheRootDir);
$this->oInterfaceDiscovery->SetCacheService($this->oCacheService);
}
@@ -103,7 +103,7 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
public function testShouldNotProduceCacheForDevelopers()
{
DataModelDependantCache::GetInstance()->Clear('InterfaceDiscovery');
$this->oCacheService->Clear('InterfaceDiscovery');
MetaModel::GetConfig()->Set('developer_mode.enabled', true);
MetaModel::GetConfig()->Set('developer_mode.interface_cache.enabled', false);
@@ -114,7 +114,7 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
public function testShouldProduceDynamicCacheForDevelopersWillingTo()
{
DataModelDependantCache::GetInstance()->Clear('InterfaceDiscovery');
$this->oCacheService->Clear('InterfaceDiscovery');
MetaModel::GetConfig()->Set('developer_mode.enabled', true);
MetaModel::GetConfig()->Set('developer_mode.interface_cache.enabled', true);
@@ -131,7 +131,7 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
public function testShouldProduceStaticCacheForProduction()
{
DataModelDependantCache::GetInstance()->Clear('InterfaceDiscovery');
$this->oCacheService->Clear('InterfaceDiscovery');
MetaModel::GetConfig()->Set('developer_mode.enabled', false);