function ViewsFieldApiTestHelper::createUser

1 call to ViewsFieldApiTestHelper::createUser()
viewsFieldApiDataTest::setUp in tests/field/views_fieldapi.test
Sets up a Drupal site for running functional and integration tests.

File

tests/field/views_fieldapi.test, line 42

Class

ViewsFieldApiTestHelper
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->drupalCreateRole($permissions))) {
        return FALSE;
    }
    // Create a user assigned to that role.
    $edit = array();
    $edit['name'] = $this->randomName();
    $edit['mail'] = $edit['name'] . '@example.com';
    $edit['roles'] = array(
        $rid => $rid,
    );
    $edit['pass'] = user_password();
    $edit['status'] = 1;
    $edit += $extra_edit;
    $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;
}