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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | role_delegation_simpletest_D7_2.patch | 11.12 KB | Andrew Schulman |
| role_delegation_simpletest_D7.patch | 11.3 KB | Andrew Schulman |
Comments
Comment #1
Andrew Schulman commentedComment #2
Andrew Schulman commentedHere's a slightly revised patch:
Comment #3
Andrew Schulman commentedFixed in 7.x-1.x-dev. See also #505224: Write test cases, which I didn't see before and suggests many other test cases.