You are here

function AutoassignroleAdminUserTestCase::testAdminUserRolesSettings in Auto Assign Role 7.2

Same name and namespace in other branches
  1. 7 autoassignrole.test \AutoassignroleAdminUserTestCase::testAdminUserRolesSettings()

Test admin setting functionality for autoassignrole_user_roles.

See also

http://drupal.org/node/944922

File

./autoassignrole.test, line 293
Creates tests for auto assign role module.

Class

AutoassignroleAdminUserTestCase
Extend the DrupalWebTestCase.

Code

function testAdminUserRolesSettings() {

  // 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/user');

  // Verify that there are roles exposed.
  $this
    ->assertField('autoassignrole_user_roles[' . $this->roles[3] . ']', 'Looking for the autoassignrole_user_roles checkboxes.');

  // Verify that a checkbox for each of our valid roles shows on the page.
  foreach ($this->roles as $rid => $role) {
    $edit["autoassignrole_user_roles[{$role}]"] = $role;
  }

  // Check each of our roles and submit the form.
  $this
    ->drupalPost('admin/config/people/autoassignrole/user', $edit, t('Save configuration'));

  // Verify the checked value was saved for each of our roles.
  $roles = variable_get("autoassignrole_user_roles", array());
  foreach ($this->roles as $rid => $role) {
    $this
      ->assertEqual(TRUE, array_key_exists($role, $roles), 'Verifying that role "' . $role . '" was activated.');
  }
}