function AutoassignroleAdminAutoTestCase::testAutoRolesSettings in Auto Assign Role 7
Same name and namespace in other branches
- 7.2 autoassignrole.test \AutoassignroleAdminAutoTestCase::testAutoRolesSettings()
Test admin setting functionality for autoassignrole_auto_roles.
See also
File
- ./
autoassignrole.test, line 157 - Creates tests for auto assign role module.
Class
- AutoassignroleAdminAutoTestCase
- Extend the DrupalWebTestCase.
Code
function testAutoRolesSettings() {
// Create a new user who can access the administration settings.
$this
->drupalLogin($this->admin_user);
// Check that the user can see the admin settings page.
$this
->drupalGet('admin/config/people/autoassignrole/auto');
// Verify that there are roles exposed.
$this
->assertField('autoassignrole_auto_roles[3]', 'Looking for the autoassignrole_auto_roles checkboxes.');
// Verify that a checkbox for each of our valid roles shows on the page.
foreach ($this->roles as $rid => $role) {
$edit["autoassignrole_auto_roles[{$rid}]"] = $rid;
}
// Check each of our roles and submit the form.
$this
->drupalPost('admin/config/people/autoassignrole/auto', $edit, t('Save configuration'));
// Verify the checked value was saved for each of our roles.
$roles = variable_get("autoassignrole_auto_roles", array());
foreach ($this->roles as $rid => $role) {
$this
->assertEqual(TRUE, array_key_exists($rid, $roles), 'Verifying that role (rid:' . $rid . ') was activated.');
}
}