class FeedsCSVtoUsersTest in Feeds 7.2
Same name and namespace in other branches
- 6 tests/feeds_processor_user.test \FeedsCSVtoUsersTest
- 7 tests/feeds_processor_user.test \FeedsCSVtoUsersTest
Test aggregating a feed as data records.
Hierarchy
- class \DrupalTestCase
- class \DrupalWebTestCase
- class \FeedsWebTestCase
- class \FeedsCSVtoUsersTest
- class \FeedsWebTestCase
- class \DrupalWebTestCase
Expanded class hierarchy of FeedsCSVtoUsersTest
File
- tests/
feeds_processor_user.test, line 11 - Tests for plugins/FeedsUserProcessor.inc.
View source
class FeedsCSVtoUsersTest extends FeedsWebTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'CSV import to users',
'description' => 'Tests a standalone import configuration that uses file fetcher and CSV parser to import users from a CSV file.',
'group' => 'Feeds',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
// Include FeedsProcessor.inc to make its constants available.
module_load_include('inc', 'feeds', 'plugins/FeedsProcessor');
// Create an importer.
$this
->createImporterConfiguration('User import', 'user_import');
// Set and configure plugins.
$this
->setPlugin('user_import', 'FeedsFileFetcher');
$this
->setPlugin('user_import', 'FeedsCSVParser');
$this
->setPlugin('user_import', 'FeedsUserProcessor');
// Go to mapping page and create a couple of mappings.
$mappings = array(
0 => array(
'source' => 'name',
'target' => 'name',
'unique' => FALSE,
),
1 => array(
'source' => 'mail',
'target' => 'mail',
'unique' => TRUE,
),
2 => array(
'source' => 'since',
'target' => 'created',
),
3 => array(
'source' => 'password',
'target' => 'pass',
),
);
$this
->addMappings('user_import', $mappings);
// Use standalone form.
$edit = array(
'content_type' => '',
);
$this
->drupalPost('admin/structure/feeds/user_import/settings', $edit, 'Save');
}
/**
* Test user creation, refreshing/deleting feeds and feed items.
*/
public function test() {
// 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 3 users');
// 1 user has an invalid email address, all users should be assigned
// the manager role.
$this
->assertText('Failed importing 2 users.');
$this
->drupalGet('admin/people');
$this
->assertText('Morticia');
$this
->assertText('Fester');
$this
->assertText('Gomez');
$count = db_query("SELECT count(*) FROM {users_roles} WHERE rid = :rid", array(
':rid' => $manager_rid,
))
->fetchField();
$this
->assertEqual($count, 3, t('All imported users were assigned the manager role.'));
$count = db_query("SELECT count(*) FROM {users_roles} WHERE rid = :rid", array(
':rid' => $admin_rid,
))
->fetchField();
$this
->assertEqual($count, 0, t('No imported user was assigned the administrator role.'));
// Run import again, verify no new users.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Failed importing 2 users.');
// Attempt to log in as one of the imported users.
$account = user_load_by_name('Morticia');
$this
->assertTrue($account, 'Imported user account loaded.');
$account->pass_raw = 'mort';
$this
->drupalLogin($account);
// Login as admin.
$this
->drupalLogin($this->admin_user);
// Removing a mapping forces updating without needing a different file.
// We are also testing that if we don't map anything to the user's password
// that it will keep its existing one.
$mappings = array(
3 => array(
'source' => 'password',
'target' => 'pass',
),
);
$this
->removeMappings('user_import', $mappings);
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => 2,
));
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
// Assert result.
$this
->assertText('Updated 3 users');
$this
->assertText('Failed importing 2 user');
// Attempt to log in as one of the imported users.
$this
->feedsLoginUser('Fester', 'fest');
// Login as admin.
$this
->drupalLogin($this->admin_user);
// Import modified CSV file, one (valid) user is missing.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => 2,
'update_non_existent' => 'block',
));
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users2.csv');
$this
->assertText('Blocked 1 user');
$this
->assertText('Failed importing 2 user');
// Import the original CSV file again.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Updated 1 user');
$this
->assertText('Failed importing 2 user');
}
/**
* Tests mapping to user ID.
*/
public function testUidTarget() {
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Add mapping to user ID.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'uid',
'target' => 'uid',
'unique' => TRUE,
),
));
// Create account with uid 202. The username and mail address of this account
// should be updated.
user_save(drupal_anonymous_user(), array(
'uid' => 202,
'name' => 'Joe',
'mail' => 'joe@example.com',
'pass' => 'joe',
'status' => 1,
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Created 2 users');
$this
->assertText('Updated 1 user');
// Assert user ID's.
$account = user_load_by_name('Morticia');
$this
->assertEqual(201, $account->uid, 'Morticia got user ID 201.');
$account = user_load_by_name('Gomez');
$this
->assertEqual(203, $account->uid, 'Gomez got user ID 203.');
// Assert that the username and mail address of account 202 were changed.
$account = user_load(202);
$values = array(
'name' => array(
'expected' => 'Fester',
'actual' => $account->name,
),
'mail' => array(
'expected' => 'fester@example.com',
'actual' => $account->mail,
),
);
$this
->assertEqual($values['name']['expected'], $values['name']['actual'], format_string('Username of account 202 changed in @expected (actual: @actual).', array(
'@expected' => $values['name']['expected'],
'@actual' => $values['name']['actual'],
)));
$this
->assertEqual($values['mail']['expected'], $values['mail']['actual'], format_string('Mail address of account 202 changed in @expected (actual: @actual).', array(
'@expected' => $values['mail']['expected'],
'@actual' => $values['mail']['actual'],
)));
// Assert that user Joe no longer exists in the system.
$this
->assertFalse(user_load_by_name('Joe'), 'No user with username Joe exists.');
$this
->assertFalse(user_load_by_mail('joe@example.com'), 'No user with mail address joe@example.com exists.');
}
/**
* Tests if user ID's can be changed using the user ID target.
*
* Also checks if a clear error is reported when trying to change the
* user ID to something that is already in use.
*/
public function testUidUpdating() {
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Add mapping to user ID, but do not mark target as unique.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'uid',
'target' => 'uid',
),
));
// Create an account which user ID should be updated.
user_save(drupal_anonymous_user(), array(
'uid' => 54,
'name' => 'Morticia',
'mail' => 'morticia@example.com',
'pass' => 'mort',
'status' => 1,
));
// Create account with uid 202. Importing an other account with uid 202
// should fail.
user_save(drupal_anonymous_user(), array(
'uid' => 202,
'name' => 'Joe',
'mail' => 'joe@example.com',
'pass' => 'joe',
'status' => 1,
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Created 1 user');
$this
->assertText('Updated 1 user');
$this
->assertText('Failed importing 3 users.');
$this
->assertText('Could not update user ID to 202 since that ID is already in use.');
// Assert Morticia's user ID got updated.
$account = user_load_by_name('Morticia');
$this
->assertEqual(201, $account->uid, 'Morticia now got user ID 201.');
// Assert that Fester failed to import.
$this
->assertFalse(user_load_by_name('Fester'), 'The account for Fester was not imported.');
// Assert that user 202 did not change.
$account = user_load(202);
$this
->assertEqual('Joe', $account->name, 'The user name of account 202 is still Joe.');
$this
->assertEqual('joe@example.com', $account->mail, 'The mail address of account 202 is still joe@example.com.');
}
/**
* Tests mapping to role without automatically creating new roles.
*/
public function testRoleTargetWithoutRoleCreation() {
// Add mapping to role.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'roles',
'target' => 'roles_list',
),
));
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia did not get the editor role and has one role in
// total.
$account = user_load_by_name('Morticia');
$this
->assertFalse(in_array('editor', $account->roles), 'Morticia does not have the editor role.');
$this
->assertEqual(1, count($account->roles), 'Morticia has one role.');
// Assert that Fester got the manager role and two roles in total.
$account = user_load_by_name('Fester');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Fester has the manager role.');
$this
->assertEqual(2, count($account->roles), 'Fester has two roles.');
// Assert that Gomez got the manager role but not the tester role, since
// that role doesn't exist on the system.
$account = user_load_by_name('Gomez');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.');
$this
->assertFalse(in_array('tester', $account->roles), 'Gomez does not have the tester role.');
$this
->assertEqual(2, count($account->roles), 'Gomez has two roles.');
// Assert that Pugsley only has one role.
$account = user_load_by_name('Pugsley');
$this
->assertEqual(1, count($account->roles), 'Pugsley has one role.');
// Assert that only three roles exist:
// - authenticated user
// - role from the admin user
// - manager
$roles = user_roles(TRUE);
$this
->assertEqual(3, count($roles), 'Only three roles exist.');
}
/**
* Tests mapping to role with automatically creating new roles.
*/
public function testRoleTargetWithRoleCreation() {
// Add mapping to role.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'roles',
'target' => 'roles_list',
'autocreate' => TRUE,
),
));
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia got the editor role and two roles in total.
$account = user_load_by_name('Morticia');
$this
->assertTrue(in_array('editor', $account->roles), 'Morticia has the editor role.');
$this
->assertEqual(2, count($account->roles), 'Morticia has two roles.');
// Assert that Fester got the manager role and two roles in total.
$account = user_load_by_name('Fester');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Fester has the manager role.');
$this
->assertEqual(2, count($account->roles), 'Fester has two roles.');
// Assert that Gomez got the manager, the editor role and three roles in
// total.
$account = user_load_by_name('Gomez');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.');
$this
->assertTrue(in_array('tester', $account->roles), 'Gomez has the tester role.');
$this
->assertEqual(3, count($account->roles), 'Gomez has three roles.');
// Assert that Pugsley only has one role.
$account = user_load_by_name('Pugsley');
$this
->assertEqual(1, count($account->roles), 'Pugsley has one role.');
// Assert that five roles exist:
// - authenticated user
// - role from the admin user
// - manager
// - editor
// - tester
$roles = user_roles(TRUE);
$this
->assertEqual(5, count($roles), 'Five roles exist.');
}
/**
* Tests mapping to role using role ID's.
*/
public function testRoleTargetRids() {
// Add mapping to role.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'rids',
'target' => 'roles_list',
'role_search' => FeedsUserProcessor::ROLE_SEARCH_RID,
),
));
// Create manager and tester roles.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
$tester_rid = $this
->drupalCreateRole(array(
'access content',
), 'tester');
// Ensure expected ID's of these roles.
$this
->assertEqual(4, $manager_rid);
$this
->assertEqual(5, $tester_rid);
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia did not get the editor role and has one role in
// total.
$account = user_load_by_name('Morticia');
$this
->assertFalse(in_array('editor', $account->roles), 'Morticia does not have the editor role.');
$this
->assertEqual(1, count($account->roles), 'Morticia has one role.');
// Assert that Fester got the manager role and two roles in total.
$account = user_load_by_name('Fester');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Fester has the manager role.');
$this
->assertEqual(2, count($account->roles), 'Fester has two roles.');
// Assert that Gomez got the manager and tester roles.
$account = user_load_by_name('Gomez');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the tester role.');
$this
->assertEqual(3, count($account->roles), 'Gomez has two roles.');
// Assert that Pugsley only has one role.
$account = user_load_by_name('Pugsley');
$this
->assertEqual(1, count($account->roles), 'Pugsley has one role.');
// Assert that four roles exist:
// - authenticated user
// - role from the admin user
// - manager
// - tester
$roles = user_roles(TRUE);
$this
->assertEqual(4, count($roles), 'Four roles exist.');
}
/**
* Tests mapping to role using only allowed roles.
*/
public function testRoleTargetWithAllowedRoles() {
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Create editor role.
$editor_rid = $this
->drupalCreateRole(array(
'access content',
), 'editor');
// Add mapping to role.
// The manager role may not be assigned to the user by the feed.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'roles',
'target' => 'roles_list',
'allowed_roles' => array(
$manager_rid => FALSE,
$editor_rid => $editor_rid,
),
'autocreate' => TRUE,
),
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia got the editor role and two roles in total.
$account = user_load_by_name('Morticia');
$this
->assertTrue(in_array('editor', $account->roles), 'Morticia has the editor role.');
$this
->assertEqual(2, count($account->roles), 'Morticia has two roles.');
// Assert that Fester did not got the manager role, because that role was
// not an allowed value.
$account = user_load_by_name('Fester');
$this
->assertFalse(isset($account->roles[$manager_rid]), 'Fester does not have the manager role.');
$this
->assertEqual(1, count($account->roles), 'Fester has one role.');
// Assert that Gomez only got the tester role and not the manager role.
$account = user_load_by_name('Gomez');
$this
->assertFalse(isset($account->roles[$manager_rid]), 'Gomez does not have the manager role.');
$this
->assertTrue(in_array('tester', $account->roles), 'Gomez has the tester role.');
$this
->assertEqual(2, count($account->roles), 'Gomez has two roles.');
}
/**
* Tests that roles can be revoked and that only allowed roles are revoked.
*/
public function testRoleTargetRevokeRoles() {
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Create editor role.
$editor_rid = $this
->drupalCreateRole(array(
'access content',
), 'editor');
// Create tester role.
$tester_rid = $this
->drupalCreateRole(array(
'access content',
), 'tester');
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Add mapping to role.
// The manager role may not be revoked, but the editor role may.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'roles',
'target' => 'roles_list',
'allowed_roles' => array(
$manager_rid => FALSE,
$editor_rid => $editor_rid,
$tester_rid => $tester_rid,
),
),
));
// Create account for Morticia with roles "manager" and "editor". In the
// source only "editor" is specified. Morticia should keep both roles.
user_save(drupal_anonymous_user(), array(
'name' => 'Morticia',
'mail' => 'morticia@example.com',
'pass' => 'mort',
'status' => 1,
'roles' => array(
$manager_rid => $manager_rid,
$editor_rid => $editor_rid,
),
));
// Create account for Pugsley with roles "manager", "editor" and "tester".
// Pugsley has no roles in the source so should only keep the "manager"
// role.
user_save(drupal_anonymous_user(), array(
'name' => 'Pugsley',
'mail' => 'pugsley@example.com',
'pass' => 'pugs',
'status' => 1,
'roles' => array(
$manager_rid => $manager_rid,
$editor_rid => $editor_rid,
$tester_rid => $tester_rid,
),
));
// Create account for Gomez and give it the "editor" role. Gomez has roles
// "tester" and "manager" in the source, so it should lose the "editor" role
// and gain the "tester" role.
user_save(drupal_anonymous_user(), array(
'name' => 'Gomez',
'mail' => 'gomez@example.com',
'pass' => 'gome',
'status' => 1,
'roles' => array(
$editor_rid => $editor_rid,
),
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia kept the manager and editor roles.
$account = user_load_by_name('Morticia');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Morticia still has the manager role.');
$this
->assertTrue(isset($account->roles[$editor_rid]), 'Morticia has the editor role.');
$this
->assertEqual(3, count($account->roles), 'Morticia has three roles.');
// Assert that Pugsley only kept the manager role.
$account = user_load_by_name('Pugsley');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Pugsley still has the manager role.');
$this
->assertFalse(isset($account->roles[$editor_rid]), 'Pugsley no longer has the editor role.');
$this
->assertFalse(isset($account->roles[$tester_rid]), 'Pugsley no longer has the tester role.');
$this
->assertEqual(2, count($account->roles), 'Pugsley has two roles.');
// Assert that Gomez lost the editor role, and gained the tester role.
$account = user_load_by_name('Gomez');
$this
->assertFalse(isset($account->roles[$editor_rid]), 'Gomez no longer has the editor role.');
$this
->assertTrue(isset($account->roles[$tester_rid]), 'Gomez has the tester role.');
$this
->assertEqual(2, count($account->roles), 'Gomez has two roles.');
}
/**
* Tests if no roles are revoked if the option "Revoke roles" is disabled.
*/
public function testRoleTargetNoRevokeRoles() {
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Create editor role.
$editor_rid = $this
->drupalCreateRole(array(
'access content',
), 'editor');
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Add mapping to role. Set option to not revoke roles.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'roles',
'target' => 'roles_list',
'allowed_roles' => array(
$manager_rid => FALSE,
$editor_rid => $editor_rid,
),
'revoke_roles' => FALSE,
),
));
// Create account for Pugsley with roles "manager" and "editor". Pugsley has
// no roles, but roles should not be revoked, so Pugsley should keep all
// roles.
user_save(drupal_anonymous_user(), array(
'name' => 'Pugsley',
'mail' => 'pugsley@example.com',
'pass' => 'pugs',
'status' => 1,
'roles' => array(
$manager_rid => $manager_rid,
$editor_rid => $editor_rid,
),
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Pugsley kept all roles.
$account = user_load_by_name('Pugsley');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Pugsley still has the manager role.');
$this
->assertTrue(isset($account->roles[$editor_rid]), 'Pugsley still has the editor role.');
$this
->assertEqual(3, count($account->roles), 'Pugsley has three roles.');
}
/**
* Tests if additional roles are assigned when creating or updating users.
*/
public function testAdditionalRolesSetting() {
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Create editor role.
$editor_rid = $this
->drupalCreateRole(array(
'access content',
), 'editor');
// Set that the "manager" role should be assigned to every user that is
// imported.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
"roles[{$manager_rid}]" => TRUE,
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Create account for Gomez and give it the "editor" role. After import
// Gomez should have the roles "editor" and "manager".
user_save(drupal_anonymous_user(), array(
'name' => 'Gomez',
'mail' => 'gomez@example.com',
'pass' => 'gome',
'status' => 1,
'roles' => array(
$editor_rid => $editor_rid,
),
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that every imported user has gained the "manager" role.
$user_names = array(
'Morticia',
'Fester',
'Pugsley',
);
foreach ($user_names as $user_name) {
$vars = array(
'@user' => $user_name,
);
// Assert that this user has the "manager" role.
$account = user_load_by_name($user_name);
$this
->assertTrue(isset($account->roles[$manager_rid]), format_string('@user has the manager role.', $vars));
$this
->assertEqual(2, count($account->roles), format_string('@user has two roles.', $vars));
}
// Assert that Gomez has gained the role "manager" and still has the
// "editor" role.
$account = user_load_by_name('Gomez');
$this
->assertTrue(isset($account->roles[$editor_rid]), 'Gomez still has the editor role.');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.');
$this
->assertEqual(3, count($account->roles), 'Gomez has three roles.');
}
/**
* Tests if additional roles are assigned when also the role mapper is used.
*/
public function testAdditionalRolesSettingWithRoleTarget() {
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Create editor role.
$editor_rid = $this
->drupalCreateRole(array(
'access content',
), 'editor');
// Create tester role.
$tester_rid = $this
->drupalCreateRole(array(
'access content',
), 'tester');
// Set that the "manager" role should be assigned to every user that is
// imported.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
"roles[{$manager_rid}]" => TRUE,
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Add mapping to role.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'roles',
'target' => 'roles_list',
),
));
// Create account for Morticia with roles "manager" and "tester". In the
// source, Morticia does not have the "manager" role, but because on the
// user processor settings that is an additional role to add, that role
// should not be revoked. The "tester" role, on the other hand, should be
// revoked.
user_save(drupal_anonymous_user(), array(
'name' => 'Morticia',
'mail' => 'morticia@example.com',
'pass' => 'mort',
'status' => 1,
'roles' => array(
$manager_rid => $manager_rid,
$tester_rid => $tester_rid,
),
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia kept the "manager" role, lost the "tester" role and
// gained the "editor" role.
$account = user_load_by_name('Morticia');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Morticia still has the manager role.');
$this
->assertTrue(isset($account->roles[$editor_rid]), 'Morticia has the editor role.');
$this
->assertFalse(isset($account->roles[$tester_rid]), 'Morticia no longer has the tester role.');
$this
->assertEqual(3, count($account->roles), 'Morticia has three roles.');
// Assert that all other imported users got the "manager" role as well.
$user_names = array(
'Fester',
'Gomez',
'Pugsley',
);
foreach ($user_names as $user_name) {
$vars = array(
'@user' => $user_name,
);
// Assert that this user has the "manager" role.
$account = user_load_by_name($user_name);
$this
->assertTrue(isset($account->roles[$manager_rid]), format_string('@user has the manager role.', $vars));
}
}
/**
* Tests if roles are replaced when replacing users.
*/
public function testAdditionalRolesSettingWhenReplacingUsers() {
// Create manager role.
$manager_rid = $this
->drupalCreateRole(array(
'access content',
), 'manager');
// Create editor role.
$editor_rid = $this
->drupalCreateRole(array(
'access content',
), 'editor');
// Set that the "manager" role should be assigned to every user that is
// imported. Other roles should be revoked.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
"roles[{$manager_rid}]" => TRUE,
'update_existing' => FEEDS_REPLACE_EXISTING,
));
// Create account for Morticia with no roles. Morticia should gain the
// "manager" role.
user_save(drupal_anonymous_user(), array(
'name' => 'Morticia',
'mail' => 'morticia@example.com',
'pass' => 'mort',
'status' => 1,
));
// Create account for Gomez and give it the "editor" role. After import
// Gomez should have lost the role "editor" and gained the role "manager".
user_save(drupal_anonymous_user(), array(
'name' => 'Gomez',
'mail' => 'gomez@example.com',
'pass' => 'gome',
'status' => 1,
'roles' => array(
$editor_rid => $editor_rid,
),
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Assert that Morticia has gained the role "manager".
$account = user_load_by_name('Morticia');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Morticia has the manager role.');
$this
->assertEqual(2, count($account->roles), 'Morticia has two roles.');
// Assert that Gomez has gained the role "manager" and but no longer has the
// "editor" role.
$account = user_load_by_name('Gomez');
$this
->assertFalse(isset($account->roles[$editor_rid]), 'Gomez no longer has the editor role.');
$this
->assertTrue(isset($account->roles[$manager_rid]), 'Gomez has the manager role.');
$this
->assertEqual(2, count($account->roles), 'Gomez has two roles.');
// Now remove all default roles and import again.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
"roles[{$manager_rid}]" => FALSE,
'skip_hash_check' => TRUE,
));
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users_roles.csv');
// Reset loaded users cache.
entity_get_controller('user')
->resetCache();
// Assert that Morticia no longer has the role "manager".
$account = user_load_by_name('Morticia');
$this
->assertFalse(isset($account->roles[$manager_rid]), 'Morticia no longer has the manager role.');
$this
->assertEqual(1, count($account->roles), 'Morticia has one role.');
}
/**
* Test if users with md5 passwords can login after import.
*/
public function testMD5() {
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Replace password mapper.
$this
->removeMappings('user_import', array(
3 => array(
'source' => 'password',
'target' => 'pass',
),
));
$this
->addMappings('user_import', array(
3 => array(
'source' => 'password_md5',
'target' => 'pass',
'pass_encryption' => 'md5',
),
));
// Create an account for Gomez, to ensure passwords can also be imported for
// existing users. Give Gomez a password different from the one that gets
// imported to ensure that his password gets updated.
user_save(drupal_anonymous_user(), array(
'name' => 'Gomez',
'mail' => 'gomez@example.com',
'pass' => 'temporary',
'status' => 1,
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
// Assert result.
$this
->assertText('Created 2 users');
$this
->assertText('Updated 1 user');
// Try to login as each successful imported user.
$this
->feedsLoginUser('Morticia', 'mort');
$this
->feedsLoginUser('Fester', 'fest');
$this
->feedsLoginUser('Gomez', 'gome');
}
/**
* Test if users with sha512 passwords can login after import.
*/
public function testSha512() {
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Replace password mapper.
$this
->removeMappings('user_import', array(
3 => array(
'source' => 'password',
'target' => 'pass',
),
));
$this
->addMappings('user_import', array(
3 => array(
'source' => 'password_sha512',
'target' => 'pass',
'pass_encryption' => 'sha512',
),
));
// Create an account for Gomez, to ensure passwords can also be imported for
// existing users. Give Gomez a password different from the one that gets
// imported to ensure that his password gets updated.
user_save(drupal_anonymous_user(), array(
'name' => 'Gomez',
'mail' => 'gomez@example.com',
'pass' => 'temporary',
'status' => 1,
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
// Assert result.
$this
->assertText('Created 2 users');
$this
->assertText('Updated 1 user');
// Try to login as each successful imported user.
$this
->feedsLoginUser('Morticia', 'mort');
$this
->feedsLoginUser('Fester', 'fest');
$this
->feedsLoginUser('Gomez', 'gome');
}
/**
* Tests mapping to timezone.
*/
public function testTimezoneTarget() {
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Add mapping to timezone.
$this
->addMappings('user_import', array(
4 => array(
'source' => 'timezone',
'target' => 'timezone',
),
));
// Create an account for Fester, to ensure that the timezone can be emptied.
user_save(drupal_anonymous_user(), array(
'name' => 'Fester',
'mail' => 'fester@example.com',
'pass' => 'fest',
'status' => 1,
'timezone' => 'Europe/Lisbon',
));
// Import CSV file.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
// Assert that Morticia got the UTC timezone.
$account = user_load_by_name('Morticia');
$this
->assertEqual('UTC', $account->timezone, 'Morticia has the UTC timezone.');
// Assert that Fester did not get any timezone.
$account = user_load_by_name('Fester');
$this
->assertFalse($account->timezone, 'Fester does not have any timezone');
// Assert that Gomez doesn't exist after import and appropriate message is
// displayed.
$account = user_load_by_name('Gomez');
$this
->assertFalse($account, "Gomez doesn't exist after import.");
$this
->assertText("Failed importing 'Gomez'. User's timezone is not valid.");
}
/**
* Tests if user 1 cannot be deleted using the delete non-existing feature.
*/
public function testUser1ProtectionWhenDeletingNonExistent() {
// Set to delete non-existing users.
$this
->setSettings('user_import', 'FeedsFileFetcher', array());
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
'update_non_existent' => 'delete',
));
// Set mail address of user 1 to "fester@example.com". An user with this
// mail address is missing in the feed later.
$account = user_load(1);
$edit['mail'] = 'fester@example.com';
user_save($account, $edit);
// Import the first file, which contains the mail address of user 1.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Updated 1 user');
// Ensure the username of user 1 was updated.
$account = user_load(1, TRUE);
$this
->assertEqual('Fester', $account->name);
// Now import the second file, where the mail address of user 1 is missing.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users2.csv');
$this
->assertNoText('Removed 1 user');
// Ensure that user 1 still exists.
$account = db_select('users')
->fields('users')
->condition('uid', 1)
->execute()
->fetch();
$this
->assertTrue(is_object($account), 'User 1 still exists.');
}
/**
* Tests if user 1 cannot be deleted using the delete form.
*/
public function testUser1ProtectionWhenDeletingAll() {
// Set to update existing users.
$this
->setSettings('user_import', 'FeedsFileFetcher', array());
$this
->setSettings('user_import', 'FeedsUserProcessor', array(
'update_existing' => FEEDS_UPDATE_EXISTING,
));
// Set mail address of user 1 to "fester@example.com".
$account = user_load(1);
$edit['mail'] = 'fester@example.com';
user_save($account, $edit);
// Import a file that contains the mail address of user 1.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/users.csv');
$this
->assertText('Updated 1 user');
// Ensure the username of user 1 was updated.
$account = user_load(1, TRUE);
$this
->assertEqual('Fester', $account->name);
// Now delete all items. User 1 should not be deleted.
$this
->drupalPost('import/user_import/delete-items', array(), 'Delete');
// Ensure that user 1 still exists.
$account = db_select('users')
->fields('users')
->condition('uid', 1)
->execute()
->fetch();
$this
->assertTrue(is_object($account), 'User 1 still exists.');
// But ensure that the associated feeds item did got deleted.
$count = db_select('feeds_item')
->fields('feeds_item')
->condition('entity_type', 'user')
->condition('entity_id', 1)
->countQuery()
->execute()
->fetchField();
$this
->assertEqual(0, $count, 'The feeds item for user 1 was deleted.');
}
/**
* Tests if an user with an invalid name is not imported.
*/
public function testInvalidUsername() {
// Import a file that contains the mail address of user 1.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/user_validation/invalid-username.csv');
$this
->assertText('Failed importing 1 user');
$this
->assertText('The username contains an illegal character.');
}
/**
* Tests importing an user which name is already taken.
*/
public function testUserNameAlreadyTaken() {
// Create an account.
user_save(drupal_anonymous_user(), array(
'name' => 'Morticia',
'mail' => 'morticia2@example.com',
'pass' => 'mort',
'status' => 1,
));
// Import a file that contains a username that is already taken.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/user_validation/username-already-taken.csv');
$this
->assertText('Failed importing 1 user');
$this
->assertText("The name 'Morticia' is already taken.");
}
/**
* Tests importing an user which mail address is already taken.
*/
public function testMailAlreadyTaken() {
// Do not mark mail address as unique.
$path = 'admin/structure/feeds/user_import/mapping';
$this
->drupalPostAJAX($path, array(), 'mapping_settings_edit_1');
$edit = array(
"config[1][settings][unique]" => FALSE,
);
$this
->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_1');
$this
->drupalPost(NULL, array(), t('Save'));
// Create an account.
user_save(drupal_anonymous_user(), array(
'name' => 'Morticia2',
'mail' => 'morticia@example.com',
'pass' => 'mort',
'status' => 1,
));
// Import a file that contains a mail address that is already taken.
$this
->importFile('user_import', $this
->absolutePath() . '/tests/feeds/user_validation/username-already-taken.csv');
$this
->assertText('Failed importing 1 user');
$this
->assertText("The e-mail address 'morticia@example.com' is already taken.");
}
/**
* Log in an imported user.
*
* @param string $username
* The user's username.
* @param string $password
* The user's password.
*/
protected function feedsLoginUser($username, $password) {
$account = user_load_by_name($username);
$this
->assertTrue($account, 'Imported user account loaded.');
$account->pass_raw = $password;
$this
->drupalLogin($account);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalTestCase:: |
protected | property | Assertions thrown in that test case. | |
DrupalTestCase:: |
protected | property | The database prefix of this test run. | |
DrupalTestCase:: |
protected | property | The original file directory, before it was changed for testing purposes. | |
DrupalTestCase:: |
public | property | Current results of this test case. | |
DrupalTestCase:: |
protected | property | Flag to indicate whether the test has been set up. | |
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | This class is skipped when looking for the source of an assertion. | |
DrupalTestCase:: |
protected | property | The test run ID. | |
DrupalTestCase:: |
protected | property | Time limit for the test. | |
DrupalTestCase:: |
public | property | Whether to cache the installation part of the setUp() method. | |
DrupalTestCase:: |
public | property | Whether to cache the modules installation part of the setUp() method. | |
DrupalTestCase:: |
protected | property | URL to the verbose output file directory. | |
DrupalTestCase:: |
protected | function | Internal helper: stores the assert. | |
DrupalTestCase:: |
protected | function | Check to see if two values are equal. | |
DrupalTestCase:: |
protected | function | Check to see if a value is false (an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
protected | function | Check to see if two values are identical. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not equal. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not identical. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
public static | function | Delete an assertion record by message ID. | |
DrupalTestCase:: |
protected | function | Fire an error assertion. | 1 |
DrupalTestCase:: |
public | function | Handle errors during test runs. | 1 |
DrupalTestCase:: |
protected | function | Handle exceptions. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always negative. | |
DrupalTestCase:: |
public static | function | Converts a list of possible parameters into a stack of permutations. | |
DrupalTestCase:: |
protected | function | Cycles through backtrace until the first non-assertion method is found. | |
DrupalTestCase:: |
public static | function | Returns the database connection to the site running Simpletest. | |
DrupalTestCase:: |
public static | function | Store an assertion from outside the testing context. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always positive. | |
DrupalTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
DrupalTestCase:: |
public static | function | Generates a random string of ASCII characters of codes 32 to 126. | |
DrupalTestCase:: |
public | function | Run all tests in this class. | |
DrupalTestCase:: |
protected | function | Logs a verbose message in a text file. | |
DrupalWebTestCase:: |
protected | property | Additional cURL options. | |
DrupalWebTestCase:: |
protected | property | The content of the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | The current cookie file used by cURL. | |
DrupalWebTestCase:: |
protected | property | The cookies of the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | The handle of the current cURL connection. | |
DrupalWebTestCase:: |
protected | property | The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | The parsed version of the page. | |
DrupalWebTestCase:: |
protected | property | Whether the files were copied to the test files directory. | |
DrupalWebTestCase:: |
protected | property | The headers of the page currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | property | HTTP authentication credentials (<username>:<password>). | |
DrupalWebTestCase:: |
protected | property | HTTP authentication method | |
DrupalWebTestCase:: |
protected | property | The current user logged in using the internal browser. | |
DrupalWebTestCase:: |
protected | property | The original shutdown handlers array, before it was cleaned for testing purposes. | |
DrupalWebTestCase:: |
protected | property | The original user, before it was changed to a clean uid = 1 for testing purposes. | |
DrupalWebTestCase:: |
protected | property | The content of the page currently loaded in the internal browser (plain text version). | |
DrupalWebTestCase:: |
protected | property | The number of redirects followed during the handling of a request. | |
DrupalWebTestCase:: |
protected | property | The current session ID, if available. | |
DrupalWebTestCase:: |
protected | property | The current session name, if available. | |
DrupalWebTestCase:: |
protected | property | The URL currently loaded in the internal browser. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists with the given name or ID. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists in the current page with the given ID and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field exists in the current page with the given name and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
DrupalWebTestCase:: |
protected | function | Pass if a link with the specified label is found, and optional with the specified index. | |
DrupalWebTestCase:: |
protected | function | Pass if a link containing a given href (part) is found. | |
DrupalWebTestCase:: |
protected | function | Asserts that the most recently sent e-mail message has the given value. | |
DrupalWebTestCase:: |
protected | function | Asserts that the most recently sent e-mail message has the pattern in it. | |
DrupalWebTestCase:: |
protected | function | Asserts that the most recently sent e-mail message has the string in it. | |
DrupalWebTestCase:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
DrupalWebTestCase:: |
protected | function | Asserts that a field doesn't exist or its value doesn't match, by XPath. | |
DrupalWebTestCase:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
DrupalWebTestCase:: |
protected | function | Pass if a link with the specified label is not found. | |
DrupalWebTestCase:: |
protected | function | Pass if a link containing a given href (part) is not found. | |
DrupalWebTestCase:: |
protected | function | Asserts that a select option in the current page is not checked. | |
DrupalWebTestCase:: |
protected | function | Will trigger a pass if the perl regex pattern is not present in raw content. | |
DrupalWebTestCase:: |
protected | function | Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated. | |
DrupalWebTestCase:: |
protected | function | Asserts the page did not return the specified response code. | |
DrupalWebTestCase:: |
protected | function | Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents. | |
DrupalWebTestCase:: |
protected | function | Pass if the page title is not the given string. | |
DrupalWebTestCase:: |
protected | function | Pass if the text is found MORE THAN ONCE on the text version of the page. | |
DrupalWebTestCase:: |
protected | function | Asserts that a select option in the current page is checked. | |
DrupalWebTestCase:: |
protected | function | Will trigger a pass if the Perl regex pattern is found in the raw content. | |
DrupalWebTestCase:: |
protected | function | Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated. | |
DrupalWebTestCase:: |
protected | function | Asserts the page responds with the specified response code. | |
DrupalWebTestCase:: |
protected | function | Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents. | |
DrupalWebTestCase:: |
protected | function | Helper for assertText and assertNoText. | |
DrupalWebTestCase:: |
protected | function | Asserts themed output. | |
DrupalWebTestCase:: |
protected | function | Pass if the page title is the given string. | |
DrupalWebTestCase:: |
protected | function | Pass if the text is found ONLY ONCE on the text version of the page. | |
DrupalWebTestCase:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
DrupalWebTestCase:: |
protected | function | Pass if the internal browser's URL matches the given path. | |
DrupalWebTestCase:: |
protected | function | Builds an XPath query. | |
DrupalWebTestCase:: |
protected | function | Changes the database connection to the prefixed one. | |
DrupalWebTestCase:: |
protected | function | Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive. | |
DrupalWebTestCase:: |
protected | function | Check to make sure that the array of permissions are valid. | |
DrupalWebTestCase:: |
protected | function | Follows a link by name. | |
DrupalWebTestCase:: |
protected | function | Helper function: construct an XPath for the given set of attributes and value. | |
DrupalWebTestCase:: |
protected | function | Copy the setup cache from/to another table and files directory. | |
DrupalWebTestCase:: |
protected | function | Runs cron in the Drupal installed by Simpletest. | |
DrupalWebTestCase:: |
protected | function | Close the cURL handler and unset the handler. | |
DrupalWebTestCase:: |
protected | function | Initializes and executes a cURL request. | |
DrupalWebTestCase:: |
protected | function | Reads headers and registers errors received from the tested site. | |
DrupalWebTestCase:: |
protected | function | Initializes the cURL connection. | |
DrupalWebTestCase:: |
protected | function | Compare two files based on size and file name. | |
DrupalWebTestCase:: |
protected | function | Creates a custom content type based on default settings. | |
DrupalWebTestCase:: |
protected | function | Creates a node based on default settings. | |
DrupalWebTestCase:: |
protected | function | Creates a role with specified permissions. | |
DrupalWebTestCase:: |
protected | function | Create a user with a given set of permissions. | |
DrupalWebTestCase:: |
protected | function | Retrieves a Drupal path or an absolute path. | |
DrupalWebTestCase:: |
protected | function | Retrieve a Drupal path or an absolute path and JSON decode the result. | |
DrupalWebTestCase:: |
protected | function | Gets the current raw HTML of requested page. | |
DrupalWebTestCase:: |
protected | function | Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed… | |
DrupalWebTestCase:: |
protected | function | Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the… | |
DrupalWebTestCase:: |
protected | function | Gets an array containing all e-mails sent during this test case. | |
DrupalWebTestCase:: |
function | Get a node from the database based on its title. | ||
DrupalWebTestCase:: |
protected | function | Gets the value of the Drupal.settings JavaScript variable for the currently loaded page. | |
DrupalWebTestCase:: |
protected | function | Get a list files that can be used in tests. | |
DrupalWebTestCase:: |
protected | function | Generate a token for the currently logged in user. | |
DrupalWebTestCase:: |
protected | function | Retrieves only the headers for a Drupal path or an absolute path. | |
DrupalWebTestCase:: |
protected | function | Log in a user with the internal browser. | |
DrupalWebTestCase:: |
protected | function | ||
DrupalWebTestCase:: |
protected | function | Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser. | |
DrupalWebTestCase:: |
protected | function | Execute an Ajax submission. | |
DrupalWebTestCase:: |
protected | function | Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page. | |
DrupalWebTestCase:: |
protected | function | Sets the value of the Drupal.settings JavaScript variable for the currently loaded page. | |
DrupalWebTestCase:: |
protected | function | Takes a path and returns an absolute path. | |
DrupalWebTestCase:: |
protected | function | Get all option elements, including nested options, in a select. | |
DrupalWebTestCase:: |
protected | function | Get the selected value from a select field. | |
DrupalWebTestCase:: |
protected | function | Returns the cache key used for the setup caching. | |
DrupalWebTestCase:: |
protected | function | Get the current URL from the cURL handler. | |
DrupalWebTestCase:: |
protected | function | Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type. | |
DrupalWebTestCase:: |
protected | function | Copies the cached tables and files for a cached installation setup. | |
DrupalWebTestCase:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
DrupalWebTestCase:: |
protected | function | Preload the registry from the testing site. | |
DrupalWebTestCase:: |
protected | function | Generates a database prefix for running tests. | |
DrupalWebTestCase:: |
protected | function | Prepares the current environment for running the test. | |
DrupalWebTestCase:: |
protected | function | Recursively copy one directory to another. | |
DrupalWebTestCase:: |
protected | function | Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. | 1 |
DrupalWebTestCase:: |
protected | function | Reset all data structures after having enabled new modules. | |
DrupalWebTestCase:: |
protected | function | Store the installation setup to a cache. | |
DrupalWebTestCase:: |
protected | function | Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix. | 6 |
DrupalWebTestCase:: |
protected | function | Outputs to verbose the most recent $count emails sent. | |
DrupalWebTestCase:: |
protected | function | Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page. | |
DrupalWebTestCase:: |
function |
Constructor for DrupalWebTestCase. Overrides DrupalTestCase:: |
1 | |
FeedsCSVtoUsersTest:: |
protected | function | Log in an imported user. | |
FeedsCSVtoUsersTest:: |
public static | function | ||
FeedsCSVtoUsersTest:: |
public | function |
Sets up a Drupal site for running functional and integration tests. Overrides FeedsWebTestCase:: |
|
FeedsCSVtoUsersTest:: |
public | function | Test user creation, refreshing/deleting feeds and feed items. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if additional roles are assigned when creating or updating users. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if roles are replaced when replacing users. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if additional roles are assigned when also the role mapper is used. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if an user with an invalid name is not imported. | |
FeedsCSVtoUsersTest:: |
public | function | Tests importing an user which mail address is already taken. | |
FeedsCSVtoUsersTest:: |
public | function | Test if users with md5 passwords can login after import. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if no roles are revoked if the option "Revoke roles" is disabled. | |
FeedsCSVtoUsersTest:: |
public | function | Tests that roles can be revoked and that only allowed roles are revoked. | |
FeedsCSVtoUsersTest:: |
public | function | Tests mapping to role using role ID's. | |
FeedsCSVtoUsersTest:: |
public | function | Tests mapping to role using only allowed roles. | |
FeedsCSVtoUsersTest:: |
public | function | Tests mapping to role without automatically creating new roles. | |
FeedsCSVtoUsersTest:: |
public | function | Tests mapping to role with automatically creating new roles. | |
FeedsCSVtoUsersTest:: |
public | function | Test if users with sha512 passwords can login after import. | |
FeedsCSVtoUsersTest:: |
public | function | Tests mapping to timezone. | |
FeedsCSVtoUsersTest:: |
public | function | Tests mapping to user ID. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if user ID's can be changed using the user ID target. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if user 1 cannot be deleted using the delete form. | |
FeedsCSVtoUsersTest:: |
public | function | Tests if user 1 cannot be deleted using the delete non-existing feature. | |
FeedsCSVtoUsersTest:: |
public | function | Tests importing an user which name is already taken. | |
FeedsWebTestCase:: |
protected | property |
The profile to install as a basis for testing. Overrides DrupalWebTestCase:: |
1 |
FeedsWebTestCase:: |
public | function | Absolute path to Drupal root. | |
FeedsWebTestCase:: |
public | function | Get the absolute directory path of the feeds module. | |
FeedsWebTestCase:: |
public | function | Adds mappings to a given configuration. | |
FeedsWebTestCase:: |
protected | function |
Overrides DrupalWebTestCase::assertFieldByXPath(). Overrides DrupalWebTestCase:: |
|
FeedsWebTestCase:: |
protected | function | Asserts that a field in the current page is disabled. | |
FeedsWebTestCase:: |
protected | function | Asserts that a field in the current page is enabled. | |
FeedsWebTestCase:: |
protected | function | Asserts that the given number of nodes exist. | |
FeedsWebTestCase:: |
public | function | Assert a feeds configuration's plugins. | |
FeedsWebTestCase:: |
protected | function | Changes the author of a node and asserts the change in the UI. | |
FeedsWebTestCase:: |
public | function | Copies a directory. | |
FeedsWebTestCase:: |
public | function | Create a test feed node. Test user has to have sufficient permissions:. | |
FeedsWebTestCase:: |
public | function | Batch create a variable amount of feed nodes. All will have the same URL configured. | |
FeedsWebTestCase:: |
public | function | Create an importer configuration. | |
FeedsWebTestCase:: |
public | function | Download and extract SimplePIE. | |
FeedsWebTestCase:: |
public | function | Edit the configuration of a feed node to test update behavior. | |
FeedsWebTestCase:: |
public | function | Generate an OPML test feed. | |
FeedsWebTestCase:: |
public | function | Gets an array of current mappings from the feeds_importer config. | |
FeedsWebTestCase:: |
public | function | Helper function, retrieves node id from a URL. | |
FeedsWebTestCase:: |
public | function | Import a file through the import form. Assumes FeedsFileFetcher in place. | |
FeedsWebTestCase:: |
public | function | Import a URL through the import form. Assumes FeedsHTTPFetcher in place. | |
FeedsWebTestCase:: |
public | function | Determines if a mapping exists for a given importer. | |
FeedsWebTestCase:: |
public | function | Remove mappings from a given configuration. | |
FeedsWebTestCase:: |
public | function | Choose a plugin for a importer configuration and assert it. | |
FeedsWebTestCase:: |
public | function | Set importer or plugin settings. |