Posted by iterator on June 1, 2009 at 10:21am
Jump to:
| Project: | SimpleTest |
| Version: | 6.x-2.8 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Hi..
Is it possible to add an user to an specific role? I only found the possibility to add permissions to an user:
$this->drupalCreateUser(array('access content', 'create page content'));Do i have to add all permissions of an role or is it possible to add the role directly? For example: drupalUserRole('moderator');
Comments
#1
This isn't really possible right now using the built-in DrupalWebTestCase methods. I can really only see a couple possible solutions: add all the permissions that you need (what all of core tests do right now), run a query to add the user ID and desired role ID to the {user_roles} table.
I've been trying to improve the user role/permission APIs in core with #300993: User roles and permissions API.
#2
@Dave Reid is right. Options then are to do the db query as he suggested or submit the page in drupal that allows you set a user to a role. Depends on your test.
#3
#4
Automatically closed -- issue fixed for 2 weeks with no activity.