N°659 PHPUnit to test uniqueness rule validity check... and debug tested method (woops ! unit test will save the world ;) )

This commit is contained in:
Pierre Goiffon
2018-10-30 17:15:08 +01:00
parent af92f58265
commit f3fd47a792
2 changed files with 85 additions and 17 deletions

View File

@@ -3074,8 +3074,8 @@ abstract class MetaModel
$MANDATORY_ATTRIBUTES = array('attributes');
$UNIQUENESS_MANDATORY_KEYS_NB = count($MANDATORY_ATTRIBUTES);
$bHasDisabledKey = false;
$bHasMissingMandatoryKey = false;
$iMissingMandatoryKeysNb = 0;
$bHasMissingMandatoryKey = true;
$iMissingMandatoryKeysNb = $UNIQUENESS_MANDATORY_KEYS_NB;
$bHasAllMandatoryKeysMissing = false;
$bHasNonDisabledKeys = false;
@@ -3086,6 +3086,12 @@ abstract class MetaModel
$bHasDisabledKey = true;
continue;
}
$bHasNonDisabledKeys = true;
if (in_array($sUniquenessRuleKey, $MANDATORY_ATTRIBUTES, true)) {
$bHasMissingMandatoryKey = false;
$iMissingMandatoryKeysNb--;
}
if (($sUniquenessRuleKey === 'attributes') && (!empty($aExistingClassFields)))
{
@@ -3097,21 +3103,6 @@ abstract class MetaModel
}
}
}
if (!$aUniquenessRuleProperty)
{
if (!in_array($sUniquenessRuleKey, $MANDATORY_ATTRIBUTES, true))
{
continue;
}
$bHasMissingMandatoryKey = true;
$iMissingMandatoryKeysNb++;
continue;
}
$bHasNonDisabledKeys = true;
}
if ($iMissingMandatoryKeysNb == $UNIQUENESS_MANDATORY_KEYS_NB)