Skip to content
Snippets Groups Projects
Commit 102f6622 authored by Alex Barth's avatar Alex Barth
Browse files

#854628 DanielJohnston, alex_b: Fix user importer assigns all roles.

parent a6fe54d9
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
Feeds 6.x 1.X XXXX
------------------
- #854628 DanielJohnston, alex_b: Fix user importer assigns all roles.
- #838018 infojunkie: Mapper for Formatted Number CCK field.
- #856408 c.ex: Pass all $targets for hook_feeds_node_processor_targets_alter()
by reference.
......
......@@ -100,7 +100,7 @@ class FeedsUserProcessor extends FeedsProcessor {
// Prepare term object.
$target_account = new stdClass();
$target_account->uid = 0;
$target_account->roles = $this->config['roles'];
$target_account->roles = array_filter($this->config['roles']);
$target_account->status = $this->config['status'];
// Have parent class do the iterating.
......
......@@ -618,18 +618,32 @@ class FeedsCSVtoUsersTest extends FeedsWebTestCase {
);
$this->drupalPost('admin/build/feeds/edit/user_import/settings', $edit, 'Save');
// Create roles and assign one of them to the users to be imported.
$manager_rid = $this->drupalCreateRole(array('access content'), 'manager');
$admin_rid = $this->drupalCreateRole(array('access content'), 'administrator');
$edit = array(
"roles[$manager_rid]" => TRUE,
"roles[$admin_rid]" => FALSE,
);
$this->setSettings('user_import', 'FeedsUserProcessor', $edit);
// Import CSV file.
$this->importFile('user_import', $this->absolutePath() .'/tests/feeds/users.csv');
// Assert result.
$this->assertText('Created 4 users.');
// 1 user has an invalid email address.
// 1 user has an invalid email address, all users should be assigned
// the manager role.
$this->assertText('There was 1 user that could not be imported because either their name or their email was empty or not valid. Check import data and mapping settings on User processor.');
$this->drupalGet('admin/user/user');
$this->assertText('Morticia');
$this->assertText('Fester');
$this->assertText('Gomez');
$this->assertText('Pugsley');
$count = db_result(db_query("SELECT count(*) FROM {users_roles} WHERE rid = %d", $manager_rid));
$this->assertEqual($count, 4, t('All imported users were assigned the manager role.'));
$count = db_result(db_query("SELECT count(*) FROM {users_roles} WHERE rid = %d", $admin_rid));
$this->assertEqual($count, 0, t('No imported user was assigned the administrator role.'));
// @todo Test status setting, update existing and role settings.
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment