1 field_views.test | protected FieldViewsTestHelper::CreateUser($extra_edit = array()) |
File
- core/
modules/ field/ tests/ field_views.test, line 36 - Tests the Views integration with Field API.
Class
- FieldViewsTestHelper
- Provides some helper methods for testing fieldapi integration into views.
Code
protected function CreateUser($extra_edit = array()) {
$permissions = array('access comments', 'access content', 'post comments', 'skip comment approval');
// Create a role with the given permission set.
if (!($rid = $this->backdropCreateRole($permissions))) {
return FALSE;
}
// Create a user assigned to that role.
$user_name = $this->randomName();
$account = entity_create('user', array(
'name' => $user_name,
'mail' => $user_name . '@example.com',
'roles' => array($rid => $rid),
'pass' => user_password(),
'status' => 1,
) + $extra_edit);
$account->save();
$this->assertTrue(!empty($account->uid), t('User created with name %name and pass %pass', array('%name' => $account->name, '%pass' => $account->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 = $account->pass;
return $account;
}