You are here

function OpenIDFunctionalTestCase::testBlockedUserLogin in Drupal 7

Test that a blocked user cannot log in.

File

modules/openid/openid.test, line 248
Tests for openid.module.

Class

OpenIDFunctionalTestCase
Test discovery and login using OpenID

Code

function testBlockedUserLogin() {

  // Use a User-supplied Identity that is the URL of an XRDS document.
  $identity = url('openid-test/yadis/xrds', array(
    'absolute' => TRUE,
  ));

  // Log in and add an OpenID Identity to the account.
  $this
    ->drupalLogin($this->web_user);
  $this
    ->addIdentity($identity);
  $this
    ->drupalLogout();

  // Log in as an admin user and block the account.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer users',
  ));
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet('admin/people');
  $edit = array(
    'operation' => 'block',
    'accounts[' . $this->web_user->uid . ']' => TRUE,
  );
  $this
    ->drupalPost('admin/people', $edit, t('Update'));
  $this
    ->assertRaw('The update has been performed.', 'Account was blocked.');
  $this
    ->drupalLogout();
  $this
    ->submitLoginForm($identity);
  $this
    ->assertRaw(t('The username %name has not been activated or is blocked.', array(
    '%name' => $this->web_user->name,
  )), 'User login was blocked.');
}