public function SimpleLdapUserSyncTestCase::testSyncOnHookUserLoad in Simple LDAP 7.2
Same name and namespace in other branches
- 7 simple_ldap_user/simple_ldap_user.test \SimpleLdapUserSyncTestCase::testSyncOnHookUserLoad()
Tests synchronization using hook_user_load().
File
- simple_ldap_user/
simple_ldap_user.test, line 964 - Tests for Simple LDAP User module.
Class
Code
public function testSyncOnHookUserLoad() {
// Set the sync trigger to hook_user_load
variable_set('simple_ldap_user_sync', 'hook_user_load');
// Load configuration variables.
$attribute_name = simple_ldap_user_variable_get('simple_ldap_user_attribute_name');
// Initialize a user account object.
$account = new stdClass();
$account->name = $this->ldapUser[0]->{$attribute_name}[0];
$account->pass_raw = $this->userPassword[0];
// Log in with the test user, this should do the initial account sync
// (tested elsewhere).
$this
->drupalLogin($account);
// Generate a random value to append.
$suffix = $this
->randomName();
// Drupal is the authoritative source. Change all of the mapped fields, load
// the user, and verify synchronization.
variable_set('simple_ldap_user_source', 'drupal');
$this
->modifyLdap();
$drupal_user = user_load_multiple(array(), array(
'name' => $this->ldapUser[0]->{$attribute_name}[0],
), TRUE);
$this
->verifySync();
// LDAP is the authoritative source. Change all of the mapped fields, load
// the user, and verify synchronization.
variable_set('simple_ldap_user_source', 'ldap');
$this
->modifyLdap($suffix);
$drupal_user = user_load_multiple(array(), array(
'name' => $this->ldapUser[0]->{$attribute_name}[0],
), TRUE);
$this
->verifySync($suffix);
// Clean up by removing the suffix from the LDAP entry, and resyncing.
$this
->modifyLdap();
$drupal_user = user_load_multiple(array(), array(
'name' => $this->ldapUser[0]->{$attribute_name}[0],
), TRUE);
$this
->verifySync();
}