Here is a simple test framework for Role Delegation in D7. It comes with three test cases:

Permissions
Check that role assignment permissions are enforced, i.e. you can/can't assign a role that you have/haven't been given permission to assign.
Operations
Check that role assignment bulk operations are available, and that they add or remove roles as intended. Note: This will allow you to easily test the D7 patch that implements the operations at #598840: User Management Batch Update Options should include assign and remove role.
Role editing
Check that when a role is renamed or deleted, the corresponding role assignment permission is correctly renamed or deleted for all roles. This is #170543: Allow renaming of roles. Note: This test currently fails because this functionality hasn't been ported to D7 yet. Once a patch is available there, this test will provide a simple way to test it.

The tests all use a simple setup with two roles, 'high' and 'low', and two users, also 'high' and 'low'. The high user has the high role, and the low user has the low role. The high role is given the "assign low role" permission; no other relevant permissions are granted. This simple setup is sufficient to test all of the above cases.

Comments

Andrew Schulman’s picture

Status: Active » Needs review
Andrew Schulman’s picture

StatusFileSize
new11.12 KB

Here's a slightly revised patch:

  • Fix wrong assertion in testOperationsForgery()
  • Wrap getInfo() strings in t()
  • Simplify some xpaths
Andrew Schulman’s picture

Status: Needs review » Fixed

Fixed in 7.x-1.x-dev. See also #505224: Write test cases, which I didn't see before and suggests many other test cases.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.