public function LdapTestCase::compareFormToProperties in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_test/LdapTestCase.class.php \LdapTestCase::compareFormToProperties()
1 call to LdapTestCase::compareFormToProperties()
- LdapAuthorizationBasicTests::testUIForms in ldap_authorization/
tests/ BasicTests.test
1 method overrides LdapTestCase::compareFormToProperties()
- LdapServersTestCase::compareFormToProperties in ldap_servers/
tests/ ldap_servers.test
File
- ldap_test/
LdapTestCase.class.php, line 387
Class
Code
public function compareFormToProperties($object, $data, $item_id, $map, $lcase_transformed) {
$mismatches = [];
foreach ($data as $field_id => $values) {
$field_id = drupal_strtolower($field_id);
if (!isset($map[$field_id])) {
continue;
}
$property = $map[$field_id];
if (!is_object($object) || !property_exists($object, $property) && !property_exists($object, drupal_strtolower($property))) {
continue;
}
$property_value = $object->{$property};
// For cases where string input is not same as array.
$field_value = isset($values[$item_id + 2]) ? $values[$item_id + 2] : $values[$item_id];
if (in_array($field_id, $lcase_transformed) && is_scalar($field_value)) {
$field_value = drupal_strtolower($field_value);
}
$property_value_show = is_scalar($property_value) ? $property_value : serialize($property_value);
$field_value_show = is_scalar($field_value) ? $field_value : serialize($field_value);
if (is_array($property_value) && is_array($field_value)) {
$pass = count(array_diff($property_value, $field_value)) == 0;
}
elseif (is_scalar($property_value) && is_scalar($field_value)) {
$pass = $property_value == $field_value;
}
else {
$pass = FALSE;
}
if (!$pass) {
$mismatches[] = "property {$property} ({$property_value_show}) does not match field {$field_id} value ({$field_value_show})";
}
}
return $mismatches;
}