public function SimpleLdapUserRegistrationTestCase::formData in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap_user/simple_ldap_user.test \SimpleLdapUserRegistrationTestCase::formData()
Generate random data for user registration form.
3 calls to SimpleLdapUserRegistrationTestCase::formData()
- SimpleLdapUserRegistrationTestCase::testRegistrationValues in simple_ldap_user/
simple_ldap_user.test - Tests that the values used to register are properly saved.
- SimpleLdapUserRegistrationTestCase::testRegistrationWithEmailVerification in simple_ldap_user/
simple_ldap_user.test - Tests user registration with email verification.
- SimpleLdapUserRegistrationTestCase::testRegistrationWithoutEmailVerification in simple_ldap_user/
simple_ldap_user.test - Tests user registration without requiring email verification.
File
- simple_ldap_user/
simple_ldap_user.test, line 626 - Tests for Simple LDAP User module.
Class
Code
public function formData(&$name, &$mail) {
// Generate form data.
$edit['name'] = $name = $this
->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';
// Fill in required fields from the user attribute map.
$server = SimpleLdapServer::singleton();
$objectclass = simple_ldap_user_variable_get('simple_ldap_user_objectclass');
$must = array();
foreach ($objectclass as $o) {
foreach ($server->schema
->must($o, TRUE) as $m) {
if (!in_array($m, $must)) {
$must[] = strtolower($m);
}
}
}
$attribute_map = simple_ldap_user_variable_get('simple_ldap_user_attribute_map');
foreach ($attribute_map as $attribute) {
if (in_array($attribute['ldap'], $must)) {
if (count($attribute['drupal']) > 1) {
continue;
}
$drupal_attribute = reset($attribute['drupal']);
if (substr($drupal_attribute, 0, 1) == '#') {
$drupal_attribute = substr($drupal_attribute, 1);
}
$attributetype = $server->schema
->get('attributetypes', $attribute['ldap']);
// A syntax type of 1.3.6.1.4.1.1466.115.121.1.27 is an integer.
if (isset($attributetype['syntax']) && $attributetype['syntax'] == '1.3.6.1.4.1.1466.115.121.1.27') {
$edit[$drupal_attribute . '[und][0][value]'] = rand(1000, 65535);
}
else {
$edit[$drupal_attribute . '[und][0][value]'] = $this
->randomName();
}
}
}
return $edit;
}