public function checkAdapterRules(ObjectEntity $objectEntity, $rules)
{
//check filterable properties
if (isset($rules[ApiEntityAdapter::RULE_TYPE_FILTERABLE]) && !in_array($objectEntity->getObjectName(), $this->ignoreCheckRules)) {
$diffProperties = array_diff($rules[ApiEntityAdapter::RULE_TYPE_FILTERABLE], $objectEntity->filterable);
$this->assertEmpty($diffProperties, sprintf('filterable properties %s in specifications and adapter rules do not match', implode(' , ', $diffProperties)));
}
//check alterable properties. Alterable properties can not be createOnly
if (isset($rules[ApiEntityAdapter::RULE_TYPE_ALTERABLE])) {
$intersectProp = array_intersect($rules[ApiEntityAdapter::RULE_TYPE_ALTERABLE], $objectEntity->createOnly);
$this->assertEmpty($intersectProp, sprintf("The property %s is mutually exclusive. should be alterable or create-only. Object %s", implode(' , ', $intersectProp), $objectEntity->getObjectName()));
//alterable properties can not be readOnly
$intersectProp = array_intersect($rules[ApiEntityAdapter::RULE_TYPE_ALTERABLE], $objectEntity->readOnly);
$this->assertEmpty($intersectProp, sprintf("The property %s is mutually exclusive. should be alterable or read-only. Object %s", implode(' , ', $intersectProp), $objectEntity->getObjectName()));
}
// check data and specification properties
if (isset($rules[ApiEntityAdapter::RULE_TYPE_TO_DATA]) && !in_array($objectEntity->getObjectName(), $this->ignoreCheckRules)) {
$dataRules = $rules[ApiEntityAdapter::RULE_TYPE_TO_DATA];
if (!empty($rules[ApiEntityAdapter::RULE_TYPE_SETTINGS])) {
$dataRules = array_merge($dataRules, $rules[ApiEntityAdapter::RULE_TYPE_SETTINGS]);
}
$diffProperties = array_diff(array_keys($objectEntity->getProperties()), $dataRules);
$this->assertEmpty($diffProperties, sprintf('Properties %s in specifications and adapter rules do not match', implode(' , ', $diffProperties)));
}
}