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
Comment #1
dave reidThis 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.
Comment #2
boombatower commented@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.
Comment #3
boombatower commented