protected function LinkitsearchPluginUserTestCase::createUser in Linkit 7.3
Create a user.
We can't use drupalCreateUser() as we want to set specific usernames.
2 calls to LinkitsearchPluginUserTestCase::createUser()
- LinkitsearchPluginUserTestCase::testBasicResults in test/
linkit_search_plugin_user.test - Test that we get results back which is valid.
- LinkitsearchPluginUserTestCase::testDescription in test/
linkit_search_plugin_user.test - Test result description.
File
- test/
linkit_search_plugin_user.test, line 54 - Tests for Linkit search plugin user.
Class
- LinkitsearchPluginUserTestCase
- Test the the user search plugin.
Code
protected function createUser($extra = array()) {
// Create a user assigned to that role.
$edit = array();
$edit += $extra;
if (!isset($edit['name'])) {
$edit['name'] = $this
->randomName();
}
$edit['mail'] = $edit['name'] . '@example.com';
$edit['pass'] = user_password();
$edit['status'] = 1;
$account = user_save(drupal_anonymous_user(), $edit);
$this
->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array(
'%name' => $edit['name'],
'%pass' => $edit['pass'],
)), t('User login'));
if (empty($account->uid)) {
return FALSE;
}
// Add the raw password so that we can log in as this user.
$account->pass_raw = $edit['pass'];
return $account;
}