public function SimpleLdapUserMassImportExportTestCase::testExport in Simple LDAP 7
Same name and namespace in other branches
- 7.2 simple_ldap_user/simple_ldap_user.test \SimpleLdapUserMassImportExportTestCase::testExport()
Test mass export.
File
- simple_ldap_user/
simple_ldap_user.test, line 1194 - Tests for Simple LDAP User module.
Class
Code
public function testExport() {
// Log in as user 1.
$this
->drupalUser1Login();
// Clear cache, otherwise the export option is not present.
$this
->drupalPost('admin/config/development/performance', array(), t('Clear all caches'));
// Verify that the drupal users do not exist in LDAP.
foreach ($this->drupalUser as $drupal_user) {
$ldap_user = new SimpleLdapUser($drupal_user->name);
$this
->assertFalse($ldap_user->exists, t(':name does not exist in LDAP.', array(
':name' => $drupal_user->name,
)));
}
// Submit the export user form.
$edit = array(
'operation' => 'simple_ldap_user_export',
);
foreach ($this->drupalUser as $drupal_user) {
$edit['accounts[' . $drupal_user->uid . ']'] = TRUE;
}
$this
->drupalPost('admin/people', $edit, t('Update'));
// Verify that the users were exported to LDAP.
foreach ($this->drupalUser as $drupal_user) {
$ldap_user = new SimpleLdapUser($drupal_user->name);
$this
->assertTrue($ldap_user->exists, t(':name exists in LDAP at :dn.', array(
':name' => $drupal_user->name,
':dn' => $ldap_user->dn,
)));
$this
->verifySync('', $drupal_user->name);
// Cleanup LDAP.
$ldap_user
->delete();
$this
->assertFalse($ldap_user->exists, t(':dn was removed from LDAP', array(
':dn' => $ldap_user->dn,
)));
}
}