You are here

function AutoassignroleUserCreationTestCase::testUserAutoActiveAPI in Auto Assign Role 7.2

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

Test that auto roles are only assigned when they are enabled.

See also

http://drupal.org/node/971622

File

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

Class

AutoassignroleUserCreationTestCase
Extend the DrupalWebTestCase.

Code

function testUserAutoActiveAPI() {

  // Enable auto role assignment.
  variable_set('autoassignrole_auto_active', 0);

  // Configure to assign our random role.
  variable_set('autoassignrole_auto_roles', array(
    $this->role => $this->role,
  ));

  // Create a test user.
  $this->test_user = $this
    ->drupalCreateUser();

  // Verify test user has been assigned role.
  $this
    ->assertFALSE(array_key_exists($this->rid, $this->test_user->roles), 'User is not automatically assigned role when autoassignrole_auto_active is set to 0');
}