function DrupalTestCase::drupalCreateUserRolePerm in SimpleTest 6
Same name and namespace in other branches
- 5 drupal_test_case.php \DrupalTestCase::drupalCreateUserRolePerm()
Creates a user / role / permissions combination specified by permissions
Parameters
array $permissions Array of the permission strings:
Return value
array/boolean false if fails. fully loaded user object with added pass_raw property
41 calls to DrupalTestCase::drupalCreateUserRolePerm()
- ActionsContentTest::testActionsContent in tests/
content_actions.test - Various tests, all in one function to assure they happen in the right order.
- AddForumTest::testAddForum in tests/
forum_module.test - AddForumTest::testAddForumContainer in tests/
forum_module.test - AddTopicToForum::testAddTopicToContainer in tests/
forum_module.test - AddTopicToForum::testAddTopicToForum in tests/
forum_module.test
File
- ./
drupal_test_case.php, line 384
Class
- DrupalTestCase
- Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.
Code
function drupalCreateUserRolePerm($permissions = NULL) {
/* Create role */
$rid = $this
->drupalCreateRolePerm($permissions);
if (!$rid) {
return FALSE;
}
/* Create user */
$ua = array();
$ua['name'] = $this
->randomName();
$ua['mail'] = $ua['name'] . '@example.com';
$ua['roles'] = array(
$rid => $rid,
);
$ua['pass'] = user_password();
$ua['status'] = 1;
$u = user_save('', $ua);
$this
->assertTrue(!empty($u->uid), " [user] name: {$ua['name']} pass: {$ua['pass']} created");
if (empty($u->uid)) {
return FALSE;
}
/* Add to cleanup list */
$this->_cleanupUsers[] = $u->uid;
/* Add the raw password */
$u->pass_raw = $ua['pass'];
return $u;
}