Fix phpunit

This commit is contained in:
Laurent Destailleur 2020-11-08 16:04:54 +01:00
parent daa4d33d5b
commit 100edffdaf
3 changed files with 11 additions and 20 deletions

View File

@ -183,22 +183,18 @@ class FactureRecTest extends PHPUnit\Framework\TestCase
{ {
$retAr=array(); $retAr=array();
if (get_class($oA) !== get_class($oB)) if (get_class($oA) !== get_class($oB)) {
{
$retAr[]="Supplied objects are not of same class."; $retAr[]="Supplied objects are not of same class.";
} else { } else {
$oVarsA=get_object_vars($oA); $oVarsA=get_object_vars($oA);
$oVarsB=get_object_vars($oB); $oVarsB=get_object_vars($oB);
$aKeys=array_keys($oVarsA); $aKeys=array_keys($oVarsA);
foreach ($aKeys as $sKey) foreach ($aKeys as $sKey) {
{
if (in_array($sKey, $fieldstoignorearray)) continue; if (in_array($sKey, $fieldstoignorearray)) continue;
if (! $ignoretype && $oVarsA[$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]); $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]) 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]); $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
} }
} }

View File

@ -241,7 +241,7 @@ class FactureTest extends PHPUnit\Framework\TestCase
'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement', 'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement',
'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva', 'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva',
'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx', 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx',
'retained_warranty' ,'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement', 'specimen' 'retained_warranty' ,'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement', 'specimen', 'trackid'
) )
); );
$this->assertEquals($arraywithdiff, array()); // Actual, Expected $this->assertEquals($arraywithdiff, array()); // Actual, Expected
@ -362,22 +362,18 @@ class FactureTest extends PHPUnit\Framework\TestCase
{ {
$retAr=array(); $retAr=array();
if (get_class($oA) !== get_class($oB)) if (get_class($oA) !== get_class($oB)) {
{
$retAr[]="Supplied objects are not of same class."; $retAr[]="Supplied objects are not of same class.";
} else { } else {
$oVarsA=get_object_vars($oA); $oVarsA=get_object_vars($oA);
$oVarsB=get_object_vars($oB); $oVarsB=get_object_vars($oB);
$aKeys=array_keys($oVarsA); $aKeys=array_keys($oVarsA);
foreach ($aKeys as $sKey) foreach ($aKeys as $sKey) {
{
if (in_array($sKey, $fieldstoignorearray)) continue; if (in_array($sKey, $fieldstoignorearray)) continue;
if (! $ignoretype && $oVarsA[$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]); $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]) 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]); $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
} }
} }

View File

@ -200,7 +200,7 @@ class UserTest extends PHPUnit\Framework\TestCase
$newlocalobject=new User($this->savdb); $newlocalobject=new User($this->savdb);
$newlocalobject->initAsSpecimen(); $newlocalobject->initAsSpecimen();
$this->changeProperties($newlocalobject); $this->changeProperties($newlocalobject);
$this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin')), array()); // Actual, Expected $this->assertEquals($this->objCompare($localobject, $newlocalobject, true, array('id','socid','societe_id','specimen','note','ref','pass','pass_indatabase','pass_indatabase_crypted','pass_temp','datec','datem','datelastlogin','datepreviouslogin','trackid')), array()); // Actual, Expected
return $localobject; return $localobject;
} }
@ -340,8 +340,7 @@ class UserTest extends PHPUnit\Framework\TestCase
$oVarsB=get_object_vars($oB); $oVarsB=get_object_vars($oB);
$aKeys=array_keys($oVarsA); $aKeys=array_keys($oVarsA);
foreach ($aKeys as $sKey) { foreach ($aKeys as $sKey) {
if (in_array($sKey, $fieldstoignorearray)) if (in_array($sKey, $fieldstoignorearray)) continue;
continue;
if (! $ignoretype && ($oVarsA[$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]); $retAr[]=$sKey.' : '.(is_object($oVarsA[$sKey])?get_class($oVarsA[$sKey]):$oVarsA[$sKey]).' <> '.(is_object($oVarsB[$sKey])?get_class($oVarsB[$sKey]):$oVarsB[$sKey]);
} }