1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* simpletest for ldap servers
|
6
|
*/
|
7
|
|
8
|
|
9
|
if (function_exists('ldap_servers_module_load_include')) {
|
10
|
ldap_servers_module_load_include('php', 'ldap_test', 'LdapTestCase.class');
|
11
|
}
|
12
|
else {
|
13
|
module_load_include('php', 'ldap_test', 'LdapTestCase.class');
|
14
|
}
|
15
|
|
16
|
class LdapServersTestCase extends LdapTestCase {
|
17
|
public static function getInfo() {
|
18
|
return array(
|
19
|
'name' => 'LDAP Servers Tests',
|
20
|
'description' => 'Test ldap servers. Servers module is primarily a storage
|
21
|
tool for ldap server configuration, so most of testing is just form and db testing.
|
22
|
there are some api like functions that are also tested.',
|
23
|
'group' => 'LDAP Servers'
|
24
|
);
|
25
|
}
|
26
|
|
27
|
function __construct($test_id = NULL) {
|
28
|
parent::__construct($test_id);
|
29
|
}
|
30
|
|
31
|
public $module_name = 'ldap_servers';
|
32
|
protected $ldap_test_data;
|
33
|
|
34
|
/**
|
35
|
* create one or more server configurations in such as way
|
36
|
* that this setUp can be a prerequisite for ldap_authentication and ldap_authorization
|
37
|
*/
|
38
|
|
39
|
function setUp() {
|
40
|
parent::setUp(array('ldap_test'));
|
41
|
variable_set('ldap_simpletest', 2);
|
42
|
}
|
43
|
|
44
|
function tearDown() {
|
45
|
parent::tearDown();
|
46
|
variable_del('ldap_help_watchdog_detail');
|
47
|
variable_del('ldap_simpletest');
|
48
|
}
|
49
|
|
50
|
public function testApiFunctions() {
|
51
|
|
52
|
$group = 'ldap_servers: functions';
|
53
|
|
54
|
foreach (array('openldap1', 'activedirectory1') as $sid) { // , 'activedirectory1'
|
55
|
$ldap_type = ($sid == 'openldap1') ? 'Open Ldap' : 'Active Directory';
|
56
|
$this->prepTestData('hogwarts', array($sid));
|
57
|
|
58
|
$group = "ldap_servers: functions: $ldap_type";
|
59
|
$test_data = variable_get('ldap_test_server__' . $sid, array());
|
60
|
ldap_servers_module_load_include('php', 'ldap_test', 'LdapServerTest.class');
|
61
|
$ldap_server = LdapServerTest::getLdapServerObjects($sid, NULL, TRUE);
|
62
|
|
63
|
// check against csv data rather than ldap array to make sure csv to ldap conversion is correct
|
64
|
$user_csv_entry = $test_data['csv']['users']['101'];
|
65
|
$user_dn = $user_csv_entry['dn'];
|
66
|
$user_cn = $user_csv_entry['cn'];
|
67
|
$user_ldap_entry = $test_data['ldap'][$user_dn];
|
68
|
|
69
|
$username = $ldap_server->userUsernameFromLdapEntry($user_ldap_entry);
|
70
|
$this->assertTrue($username == $user_csv_entry['cn'], 'LdapServer::userUsernameFromLdapEntry works when LdapServer::user_attr attribute used', $group);
|
71
|
|
72
|
$bogus_ldap_entry = array();
|
73
|
$username = $ldap_server->userUsernameFromLdapEntry($bogus_ldap_entry);
|
74
|
$this->assertTrue($username === FALSE, 'LdapServer::userUsernameFromLdapEntry fails correctly', $group);
|
75
|
|
76
|
$username = $ldap_server->userUsernameFromDn($user_dn);
|
77
|
$this->assertTrue($username == $user_cn, 'LdapServer::userUsernameFromDn works when LdapServer::user_attr attribute used', $group);
|
78
|
|
79
|
$username = $ldap_server->userUsernameFromDn('bogus dn');
|
80
|
$this->assertTrue($username === FALSE, 'LdapServer::userUsernameFromDn fails correctly', $group);
|
81
|
|
82
|
$desired = array();
|
83
|
$desired[0] = array(
|
84
|
0 => 'cn=gryffindor,ou=groups,dc=hogwarts,dc=edu',
|
85
|
1 => 'cn=students,ou=groups,dc=hogwarts,dc=edu',
|
86
|
2 => 'cn=honors students,ou=groups,dc=hogwarts,dc=edu',
|
87
|
);
|
88
|
$desired[1] = array_merge($desired[0], array('cn=users,ou=groups,dc=hogwarts,dc=edu'));
|
89
|
|
90
|
foreach (array(0, 1) as $nested) {
|
91
|
|
92
|
$nested_display = ($nested) ? 'nested' : 'not nested';
|
93
|
$desired_count = ($nested) ? 4 : 3;
|
94
|
$ldap_module_user_entry = array('attr' => $user_ldap_entry, 'dn' => $user_dn);
|
95
|
$groups_desired = $desired[$nested];
|
96
|
|
97
|
$suffix = ",desired=$desired_count, nested=" . (boolean)$nested;
|
98
|
|
99
|
// test parent function groupMembershipsFromUser
|
100
|
$groups = $ldap_server->groupMembershipsFromUser($ldap_module_user_entry, 'group_dns', $nested);
|
101
|
$count = count($groups);
|
102
|
$diff1 = array_diff($groups_desired, $groups);
|
103
|
$diff2 = array_diff($groups, $groups_desired);
|
104
|
$pass = (count($diff1) == 0 && count($diff2) == 0 && $count == $desired_count);
|
105
|
$this->assertTrue($pass, "LdapServer::groupMembershipsFromUser nested=$nested", $group . $suffix);
|
106
|
if (!$pass) {
|
107
|
debug('groupMembershipsFromUser');debug($groups); debug($diff1); debug($diff2); debug($groups_desired);
|
108
|
}
|
109
|
|
110
|
// test parent groupUserMembershipsFromUserAttr, for openldap should be false, for ad should work
|
111
|
$groups = $ldap_server->groupUserMembershipsFromUserAttr($ldap_module_user_entry, $nested);
|
112
|
$count = is_array($groups) ? count($groups) : $count;
|
113
|
$pass = $count === FALSE;
|
114
|
if ($sid == 'openldap1') {
|
115
|
$pass = ($groups === FALSE);
|
116
|
}
|
117
|
else {
|
118
|
$pass = (count($diff1) == 0 && count($diff2) == 0 && $count == $desired_count);
|
119
|
}
|
120
|
$this->assertTrue($pass, "LdapServer::groupUserMembershipsFromUserAttr $nested_display, $ldap_type, is false because not configured", $group . $suffix);
|
121
|
if (!$pass) {
|
122
|
debug('groupUserMembershipsFromUserAttr');debug($groups); debug($diff1); debug($diff2);
|
123
|
}
|
124
|
|
125
|
$groups = $ldap_server->groupUserMembershipsFromEntry($ldap_module_user_entry, $nested);
|
126
|
$count = count($groups);
|
127
|
$diff1 = array_diff($groups_desired, $groups);
|
128
|
$diff2 = array_diff($groups, $groups_desired);
|
129
|
$pass = (count($diff1) == 0 && count($diff2) == 0 && $count == $desired_count);
|
130
|
$this->assertTrue($pass, "LdapServer::groupUserMembershipsFromEntry $nested_display works", $group . $suffix);
|
131
|
if (!$pass) {
|
132
|
debug('groupUserMembershipsFromEntry'); debug($groups); debug($diff1); debug($diff2); debug($groups_desired );
|
133
|
}
|
134
|
}
|
135
|
}
|
136
|
}
|
137
|
|
138
|
|
139
|
public function testInstall() {
|
140
|
$group = 'ldap_servers: install and uninstall';
|
141
|
$install_tables = array('ldap_servers');
|
142
|
// disable, uninstall, and enable/install module
|
143
|
$modules = array($this->module_name);
|
144
|
$ldap_module_uninstall_sequence = array('ldap_authentication', 'ldap_test', 'ldap_user', 'ldap_group', 'ldap_servers');
|
145
|
module_disable($ldap_module_uninstall_sequence); // disable dependent modules
|
146
|
drupal_uninstall_modules($ldap_module_uninstall_sequence);
|
147
|
module_enable($modules, TRUE);
|
148
|
foreach ($install_tables as $table) {
|
149
|
$this->assertTrue(db_table_exists($table), $table . ' table creates', $group);
|
150
|
}
|
151
|
$var_created = $this->assertTrue(TRUE, 'ldap_servers_encryption variable initialized', $group);
|
152
|
$var_created = $this->assertTrue(variable_get('ldap_servers_encrypt_key', drupal_get_hash_salt()), 'ldap_servers_encrypt_key variable initialized', $group);
|
153
|
|
154
|
module_disable($modules, TRUE); // disable dependent modules
|
155
|
drupal_uninstall_modules($modules, TRUE); // unistall dependent modules
|
156
|
foreach ($install_tables as $table) {
|
157
|
$this->assertFalse(db_table_exists($table), $table . ' table removed', $group);
|
158
|
}
|
159
|
$var_created = $this->assertFalse(variable_get('ldap_servers_encryption', FALSE), 'ldap_servers_encryption variable removed', $group);
|
160
|
$var_created = $this->assertFalse(variable_get('ldap_servers_encrypt_key', FALSE), 'ldap_servers_encrypt_key variable removed', $group);
|
161
|
|
162
|
|
163
|
// test tokens, see http://drupal.org/node/1245736
|
164
|
$ldap_entry = array(
|
165
|
'dn' => 'cn=hpotter,ou=people,dc=hogwarts,dc=edu',
|
166
|
'mail' => array( 0 => 'hpotter@hogwarts.edu', 'count' => 1),
|
167
|
'sAMAccountName' => array( 0 => 'hpotter', 'count' => 1),
|
168
|
'house' => array( 0 => 'Gryffindor', 1 => 'Privet Drive', 'count' => 2),
|
169
|
'guid' => array( 0 => 'sdafsdfsdf', 'count' => 1),
|
170
|
'count' => 3,
|
171
|
);
|
172
|
|
173
|
$this->ldapTestId = 'ldap_server.tokens';
|
174
|
|
175
|
$dn = ldap_servers_token_replace($ldap_entry, '[dn]');
|
176
|
$this->assertTrue( $dn == $ldap_entry['dn'], t('[dn] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
177
|
|
178
|
$house0 = ldap_servers_token_replace($ldap_entry, '[house:0]');
|
179
|
$this->assertTrue( $house0 == $ldap_entry['house'][0], t("[house:0] token worked ($house0) on ldap_servers_token_replace()."), $this->ldapTestId);
|
180
|
|
181
|
$mixed = ldap_servers_token_replace($ldap_entry, 'thisold[house:0]');
|
182
|
$this->assertTrue( $mixed == 'thisold' . $ldap_entry['house'][0], t("thisold[house:0] token worked ($mixed) on ldap_servers_token_replace()."), $this->ldapTestId);
|
183
|
|
184
|
$compound = ldap_servers_token_replace($ldap_entry, '[samaccountname:0][house:0]');
|
185
|
$this->assertTrue( $compound == $ldap_entry['sAMAccountName'][0] . $ldap_entry['house'][0], t("[samaccountname:0][house:0] compound token worked ($mixed) on ldap_servers_token_replace()."), $this->ldapTestId);
|
186
|
|
187
|
|
188
|
$literalvalue = ldap_servers_token_replace($ldap_entry, 'literalvalue');
|
189
|
$this->assertTrue( $literalvalue == 'literalvalue', t("'literalvalue' token worked ($literalvalue) on ldap_servers_token_replace()."), $this->ldapTestId);
|
190
|
|
191
|
$house0 = ldap_servers_token_replace($ldap_entry, '[house]');
|
192
|
$this->assertTrue( $house0 == $ldap_entry['house'][0], t("[house] token worked ($house0) on ldap_servers_token_replace()."), $this->ldapTestId);
|
193
|
|
194
|
$house1 = ldap_servers_token_replace($ldap_entry, '[house:last]');
|
195
|
$this->assertTrue( $house1 == $ldap_entry['house'][1], t('[house:last] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
196
|
|
197
|
$sAMAccountName = ldap_servers_token_replace($ldap_entry, '[samaccountname:0]');
|
198
|
$this->assertTrue($sAMAccountName == $ldap_entry['sAMAccountName'][0], t('[samaccountname:0] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
199
|
|
200
|
$sAMAccountNameMixedCase = ldap_servers_token_replace($ldap_entry, '[sAMAccountName:0]');
|
201
|
$this->assertTrue($sAMAccountNameMixedCase == $ldap_entry['sAMAccountName'][0], t('[sAMAccountName:0] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
202
|
|
203
|
$sAMAccountName2 = ldap_servers_token_replace($ldap_entry, '[samaccountname]');
|
204
|
$this->assertTrue($sAMAccountName2 == $ldap_entry['sAMAccountName'][0], t('[samaccountname] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
205
|
|
206
|
$sAMAccountName3 = ldap_servers_token_replace($ldap_entry, '[sAMAccountName]');
|
207
|
$this->assertTrue($sAMAccountName2 == $ldap_entry['sAMAccountName'][0], t('[sAMAccountName] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
208
|
|
209
|
$base64encode = ldap_servers_token_replace($ldap_entry, '[guid;base64_encode]');
|
210
|
$this->assertTrue($base64encode == base64_encode($ldap_entry['guid'][0]), t('[guid;base64_encode] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
211
|
|
212
|
$bin2hex = ldap_servers_token_replace($ldap_entry, '[guid;bin2hex]');
|
213
|
$this->assertTrue($bin2hex == bin2hex($ldap_entry['guid'][0]), t('[guid;bin2hex] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
214
|
|
215
|
$msguid = ldap_servers_token_replace($ldap_entry, '[guid;msguid]');
|
216
|
$this->assertTrue($msguid == ldap_servers_msguid($ldap_entry['guid'][0]), t('[guid;msguid] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
217
|
|
218
|
$binary = ldap_servers_token_replace($ldap_entry, '[guid;binary]');
|
219
|
$this->assertTrue($binary == ldap_servers_binary($ldap_entry['guid'][0]), t('[guid;binary] token worked on ldap_servers_token_replace().'), $this->ldapTestId);
|
220
|
|
221
|
/**
|
222
|
* @todo test tokens for 'user_account'
|
223
|
*
|
224
|
$account = new stdClass();
|
225
|
$account->
|
226
|
ldap_servers_token_replace($account, '[property.name]', 'user_account');
|
227
|
*/
|
228
|
|
229
|
module_enable($modules, TRUE);
|
230
|
}
|
231
|
|
232
|
public function testUIForms() {
|
233
|
|
234
|
foreach (array(1) as $ctools_enabled) {
|
235
|
$this->ldapTestId = "testUIForms.ctools.$ctools_enabled";
|
236
|
if ($ctools_enabled) {
|
237
|
module_enable(array('ctools'));
|
238
|
}
|
239
|
else {
|
240
|
// module_disable(array('ctools'));
|
241
|
}
|
242
|
|
243
|
$ldap_simpletest_initial = variable_get('ldap_simpletest', 2);
|
244
|
variable_del('ldap_simpletest'); // need to be out of fake server mode to test ui.
|
245
|
$this->privileged_user = $this->drupalCreateUser(array(
|
246
|
'administer site configuration',
|
247
|
));
|
248
|
$this->drupalLogin($this->privileged_user);
|
249
|
|
250
|
$sid = 'server1';
|
251
|
$server_data = array();
|
252
|
$server_data[$sid] = array(
|
253
|
'sid' => array($sid, $sid),
|
254
|
'name' => array("Server $sid", "My Server $sid"),
|
255
|
'status' => array(1, 1),
|
256
|
'ldap_type' => array('openldap', 'ad'),
|
257
|
'address' => array("${sid}.ldap.fake", "${sid}.ldap.fake"),
|
258
|
'port' => array(389, 7000),
|
259
|
'tls' => array(TRUE, FALSE),
|
260
|
'bind_method' => array(1, 3),
|
261
|
'binddn' => array('cn=service-account,ou=people,dc=hogwarts,dc=edu', ''),
|
262
|
'bindpw' => array('sdfsdafsdfasdf', 'sdfsdafsdfasdf'),
|
263
|
'user_attr' => array('sAMAccountName', 'blah'),
|
264
|
'account_name_attr' => array('sAMAccountName', 'blah'),
|
265
|
'mail_attr' => array('mail', ''),
|
266
|
'mail_template' => array('' , '[email]'),
|
267
|
'unique_persistent_attr' => array('dn', 'uniqueregistryid'),
|
268
|
'unique_persistent_attr_binary' => array(1, 1, 1, 1),
|
269
|
'user_dn_expression' => array('cn=%cn,%basedn', 'cn=%username,%basedn'),
|
270
|
'ldap_to_drupal_user' => array('code', 'different code'),
|
271
|
|
272
|
'testing_drupal_username' => array('hpotter', 'hpotter'),
|
273
|
'testing_drupal_user_dn' => array('cn=hpotter,ou=people,dc=hogwarts,dc=edu', 'cn=hpotter,ou=people,dc=hogwarts,dc=edu'),
|
274
|
|
275
|
'grp_unused' => array(FALSE, FALSE),
|
276
|
'grp_object_cat' => array('group', 'group'),
|
277
|
'grp_nested' => array(FALSE, FALSE),
|
278
|
|
279
|
'grp_user_memb_attr_exists' => array(1, 1),
|
280
|
'grp_user_memb_attr' => array('memberof', 'memberof'),
|
281
|
|
282
|
'grp_memb_attr' => array('member', 'member'),
|
283
|
'grp_memb_attr_match_user_attr' => array('dn', 'dn'),
|
284
|
|
285
|
'grp_derive_from_dn' => array(1, 1),
|
286
|
'grp_derive_from_dn_attr' => array('ou', 'ou'),
|
287
|
|
288
|
'grp_test_grp_dn' => array('cn=students,ou=groups,dc=hogwarts,dc=edu', 'cn=students,ou=groups,dc=hogwarts,dc=edu'),
|
289
|
'grp_test_grp_dn_writeable' => array('cn=students,ou=groups,dc=hogwarts,dc=edu', 'cn=students,ou=groups,dc=hogwarts,dc=edu'),
|
290
|
|
291
|
);
|
292
|
|
293
|
$lcase_transformed = array(
|
294
|
'user_attr',
|
295
|
'account_name_attr',
|
296
|
'mail_attr',
|
297
|
'unique_persistent_attr',
|
298
|
'grp_user_memb_attr',
|
299
|
'grp_memb_attr_match_user_attr',
|
300
|
'grp_derive_from_dn_attr'
|
301
|
);
|
302
|
|
303
|
if (!module_exists('php')) {
|
304
|
unset($server_data[$sid]['ldap_to_drupal_user']);
|
305
|
}
|
306
|
|
307
|
/** add server conf test **/
|
308
|
$this->drupalGet('admin/config/people/ldap/servers/add');
|
309
|
|
310
|
$edit = array();
|
311
|
foreach ($server_data['server1'] as $input_name => $input_values) {
|
312
|
$edit[$input_name] = $input_values[0];
|
313
|
}
|
314
|
$this->drupalPost('admin/config/people/ldap/servers/add', $edit, t('Add'));
|
315
|
$field_to_prop_map = LdapServer::field_to_properties_map();
|
316
|
$field_to_prop_map['bindpw'] = 'bindpw';
|
317
|
$ldap_servers = ldap_servers_get_servers(NULL, 'all', FALSE, TRUE);
|
318
|
$this->assertTrue(count(array_keys($ldap_servers)) == 1, 'Add form for ldap server added server.', $this->ldapTestId . ' Add Server');
|
319
|
$this->assertText('LDAP Server Server server1 added', 'Add form confirmation message', $this->ldapTestId . ' Add Server');
|
320
|
// assert one ldap server exists in db table
|
321
|
|
322
|
// assert load of server has correct properties for each input
|
323
|
$mismatches = $this->compareFormToProperties($ldap_servers['server1'], $server_data['server1'], 0, $field_to_prop_map, $lcase_transformed);
|
324
|
if (count($mismatches)) {
|
325
|
debug('mismatches between ldap server properties and form submitted values');
|
326
|
debug($mismatches);
|
327
|
debug($ldap_servers);
|
328
|
debug($server_data['server1']);
|
329
|
}
|
330
|
$this->assertTrue(count($mismatches) == 0, 'Add form for ldap server properties match values submitted.', $this->ldapTestId . ' Add Server');
|
331
|
|
332
|
|
333
|
/** update server conf test **/
|
334
|
|
335
|
$this->drupalGet('admin/config/people/ldap/servers/edit/server1');
|
336
|
|
337
|
$edit = array();
|
338
|
foreach ($server_data['server1'] as $input_name => $input_values) {
|
339
|
if ($input_values[1] !== NULL) {
|
340
|
$edit[$input_name] = $input_values[1];
|
341
|
}
|
342
|
}
|
343
|
|
344
|
unset($edit['sid']);
|
345
|
$this->drupalPost('admin/config/people/ldap/servers/edit/server1', $edit, t('Update'));
|
346
|
$ldap_servers = ldap_servers_get_servers(NULL, 'all', FALSE, TRUE);
|
347
|
$this->assertTrue(count(array_keys($ldap_servers)) == 1, 'Update form for ldap server didnt delete or add another server.', $this->ldapTestId . '.Update Server');
|
348
|
// assert confirmation message without error
|
349
|
// assert one ldap server exists in db table
|
350
|
// assert load of server has correct properties for each input
|
351
|
// unset($server_data['server1']['bindpw']);
|
352
|
$mismatches = $this->compareFormToProperties($ldap_servers['server1'], $server_data['server1'], 1, $field_to_prop_map, $lcase_transformed);
|
353
|
if (count($mismatches)) {
|
354
|
debug('mismatches between ldap server properties and form submitted values'); debug($mismatches);
|
355
|
}
|
356
|
$this->assertTrue(count($mismatches) == 0, 'Update form for ldap server properties match values submitted.', $this->ldapTestId . '.Update Server');
|
357
|
|
358
|
/** delete server conf test **/
|
359
|
$this->drupalGet('admin/config/people/ldap/servers/delete/server1');
|
360
|
$this->drupalPost('admin/config/people/ldap/servers/delete/server1', array(), t('Delete'));
|
361
|
|
362
|
$ldap_servers = ldap_servers_get_servers(NULL, 'all', FALSE, TRUE);
|
363
|
|
364
|
$this->assertTrue(count(array_keys($ldap_servers)) == 0, 'Delete form for ldap server deleted server.', $this->ldapTestId . '.Delete Server');
|
365
|
|
366
|
variable_set('ldap_simpletest', $ldap_simpletest_initial); // return to fake server mode
|
367
|
}
|
368
|
}
|
369
|
|
370
|
public function serverConfCount() {
|
371
|
$records = db_query('SELECT * FROM {ldap_servers}')->fetchAllAssoc('sid');
|
372
|
return count(array_keys($records));
|
373
|
}
|
374
|
|
375
|
public function compareFormToProperties($object, $data, $item_id, $map, $lcase_transformed) {
|
376
|
|
377
|
$mismatches = array();
|
378
|
foreach ($data as $field_id => $values) {
|
379
|
$field_id = drupal_strtolower($field_id);
|
380
|
if (!isset($map[$field_id])) {
|
381
|
// debug("no mapping for field: $field_id in item_id $item_id");
|
382
|
continue;
|
383
|
}
|
384
|
$property = $map[$field_id];
|
385
|
if (!property_exists($object, $property) && !property_exists($object, drupal_strtolower($property))) {
|
386
|
// debug("property $property does not exist in object in item_id $item_id");
|
387
|
continue;
|
388
|
}
|
389
|
$property_value = $object->{$property};
|
390
|
|
391
|
$field_value = isset($values[$item_id + 2]) ? $values[$item_id + 2] : $values[$item_id]; // for cases where string input is not same as array.
|
392
|
|
393
|
if ($field_id == 'bindpw') { //
|
394
|
continue;
|
395
|
}
|
396
|
if ($field_id == 'basedn') {
|
397
|
$pass = count($property_value) == 2;
|
398
|
if (!$pass) {
|
399
|
debug($property_value);
|
400
|
}
|
401
|
}
|
402
|
else {
|
403
|
if (in_array($field_id, $lcase_transformed) && is_scalar($field_value)) {
|
404
|
$field_value = drupal_strtolower($field_value);
|
405
|
}
|
406
|
$property_value_show = (is_scalar($property_value)) ? $property_value : serialize($property_value);
|
407
|
$field_value_show = (is_scalar($field_value)) ? $field_value : serialize($field_value);
|
408
|
|
409
|
if (is_array($property_value) && is_array($field_value)) {
|
410
|
$pass = count(array_diff($property_value, $field_value)) == 0;
|
411
|
}
|
412
|
elseif (is_scalar($property_value) && is_scalar($field_value)) {
|
413
|
$pass = ($property_value == $field_value);
|
414
|
}
|
415
|
else {
|
416
|
$pass = FALSE;
|
417
|
}
|
418
|
}
|
419
|
if (!$pass) {
|
420
|
$mismatches[] = "property $property ($property_value_show) does not match field $field_id value ($field_value_show)";
|
421
|
}
|
422
|
}
|
423
|
|
424
|
return $mismatches;
|
425
|
}
|
426
|
|
427
|
|
428
|
}
|