You are here

function AutoassignroleAdminAutoTestCase::testAutoRolesSettings in Auto Assign Role 7.2

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

Test admin setting functionality for autoassignrole_auto_roles.

See also

http://drupal.org/node/937678

File

./autoassignrole.test, line 158
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[' . $this->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 $role) {
    $edit["autoassignrole_auto_roles[{$role}]"] = $role;
  }

  // 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 $role) {
    $this
      ->assertEqual(TRUE, array_key_exists($role, $roles), sprintf('Verifying that role %s was activated.', $role));
  }
}