mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-07 17:42:53 +01:00
Normalized line endings to LF
This commit is contained in:
@@ -269,53 +269,53 @@ class UserTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Edit an object to test updates
|
||||
*
|
||||
* @param mixed &$localobject Object Facture
|
||||
* @return void
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
$localobject->note='New note after update';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare all public properties values of 2 objects
|
||||
*
|
||||
* @param Object $oA Object operand 1
|
||||
* @param Object $oB Object operand 2
|
||||
* @param boolean $ignoretype False will not report diff if type of value differs
|
||||
* @param array $fieldstoignorearray Array of fields to ignore in diff
|
||||
* @return array Array with differences
|
||||
*/
|
||||
public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB))
|
||||
{
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
foreach($aKeys as $sKey)
|
||||
{
|
||||
if (in_array($sKey,$fieldstoignorearray)) continue;
|
||||
if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
|
||||
{
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey])
|
||||
{
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retAr;
|
||||
/**
|
||||
* Edit an object to test updates
|
||||
*
|
||||
* @param mixed &$localobject Object Facture
|
||||
* @return void
|
||||
*/
|
||||
public function changeProperties(&$localobject)
|
||||
{
|
||||
$localobject->note='New note after update';
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare all public properties values of 2 objects
|
||||
*
|
||||
* @param Object $oA Object operand 1
|
||||
* @param Object $oB Object operand 2
|
||||
* @param boolean $ignoretype False will not report diff if type of value differs
|
||||
* @param array $fieldstoignorearray Array of fields to ignore in diff
|
||||
* @return array Array with differences
|
||||
*/
|
||||
public function objCompare($oA,$oB,$ignoretype=true,$fieldstoignorearray=array('id'))
|
||||
{
|
||||
$retAr=array();
|
||||
|
||||
if (get_class($oA) !== get_class($oB))
|
||||
{
|
||||
$retAr[]="Supplied objects are not of same class.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$oVarsA=get_object_vars($oA);
|
||||
$oVarsB=get_object_vars($oB);
|
||||
$aKeys=array_keys($oVarsA);
|
||||
foreach($aKeys as $sKey)
|
||||
{
|
||||
if (in_array($sKey,$fieldstoignorearray)) continue;
|
||||
if (! $ignoretype && $oVarsA[$sKey] !== $oVarsB[$sKey])
|
||||
{
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
if ($ignoretype && $oVarsA[$sKey] != $oVarsB[$sKey])
|
||||
{
|
||||
$retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $retAr;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user