OpenIDRegistrationTestCase::testRegisterUserWithoutSreg

7 openid.test OpenIDRegistrationTestCase::testRegisterUserWithoutSreg()
8 openid.test OpenIDRegistrationTestCase::testRegisterUserWithoutSreg()

Test OpenID auto-registration with a provider that does not supply SREG information (i.e. no username or e-mail address).

File

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

Code

function testRegisterUserWithoutSreg() {
  // Load the front page to get the user login block.
  $this->drupalGet('');

  // Use a User-supplied Identity that is the URL of an XRDS document.
  $identity = url('openid-test/yadis/xrds', array('absolute' => TRUE));
  $this->submitLoginForm($identity);
  $this->assertRaw(t('Complete the registration by filling out the form below. If you already have an account, you can <a href="@login">log in</a> now and add your OpenID under "My account".', array('@login' => url('user/login'))), t('User was asked to complete the registration process manually.'));
  $this->assertNoRaw(t('You must enter a username.'), t('Form validation error for username was not displayed.'));
  $this->assertNoRaw(t('You must enter an e-mail address.'), t('Form validation error for e-mail address was not displayed.'));

  // Enter username and e-mail address manually.
  $edit = array(
    'name' => 'john',
    'mail' => 'john@example.com',
  );
  $this->drupalPost(NULL, $edit, t('Create new account'));
  $this->assertRaw(t('Once you have verified your e-mail address, you may log in via OpenID.'), t('User was asked to verify e-mail address.'));
  $reset_url = $this->getPasswordResetURLFromMail();

  $user = user_load_by_name('john');
  $this->assertTrue($user, t('User was registered with right username.'));
  $this->assertFalse($user->data, t('No additional user info was saved.'));

  // Follow the one-time login that was sent in the welcome e-mail.
  $this->drupalGet($reset_url);
  $this->drupalPost(NULL, array(), t('Log in'));

  // The user is taken to user/%uid/edit.
  $this->assertFieldByName('mail', 'john@example.com', t('User was registered with right e-mail address.'));

  $this->clickLink(t('OpenID identities'));
  $this->assertRaw($identity, t('OpenID identity was registered.'));
}
Login or register to post comments