N°5491 - Inconsistent dictionnary entries regarding arguments to pass to Dict::Format-test first (#545)

This commit is contained in:
odain-cbd
2023-09-13 12:02:49 +02:00
committed by GitHub
parent e946fc65fc
commit e76728b2bf
10 changed files with 362 additions and 54 deletions

View File

@@ -222,6 +222,21 @@ abstract class ItopTestCase extends TestCase
return $method->invokeArgs($oObject, $aArgs);
}
/**
* @param string $sClass
* @param string $sProperty
*
* @return mixed property
*
* @throws \ReflectionException
* @since 2.7.10 3.1.0
*/
public function GetNonPublicStaticProperty(string $sClass, string $sProperty)
{
$oProperty = $this->GetProperty($sClass, $sProperty);
return $oProperty->getValue();
}
/**
* @param object $oObject
@@ -234,11 +249,27 @@ abstract class ItopTestCase extends TestCase
*/
public function GetNonPublicProperty(object $oObject, string $sProperty)
{
$class = new \ReflectionClass(get_class($oObject));
$property = $class->getProperty($sProperty);
$property->setAccessible(true);
$oProperty = $this->GetProperty(get_class($oObject), $sProperty);
return $property->getValue($oObject);
return $oProperty->getValue($oObject);
}
/**
* @param string $sClass
* @param string $sProperty
*
* @return \ReflectionProperty
*
* @throws \ReflectionException
* @since 2.7.10 3.1.0
*/
private function GetProperty(string $sClass, string $sProperty)
{
$oClass = new \ReflectionClass($sClass);
$oProperty = $oClass->getProperty($sProperty);
$oProperty->setAccessible(true);
return $oProperty;
}
/**
@@ -251,10 +282,22 @@ abstract class ItopTestCase extends TestCase
*/
public function SetNonPublicProperty(object $oObject, string $sProperty, $value)
{
$class = new \ReflectionClass(get_class($oObject));
$property = $class->getProperty($sProperty);
$property->setAccessible(true);
$property->setValue($oObject, $value);
$oProperty = $this->GetProperty(get_class($oObject), $sProperty);
$oProperty->setValue($oObject, $value);
}
}
/**
* @param string $sClass
* @param string $sProperty
* @param $value
*
* @throws \ReflectionException
* @since 2.7.10 3.1.0
*/
public function SetNonPublicStaticProperty(string $sClass, string $sProperty, $value)
{
$oProperty = $this->GetProperty($sClass, $sProperty);
$oProperty->setValue($value);
}
}