function OpenIDInvalidIdentifierTransitionTestCase::testStrippedFragmentAccountAutoUpdateSreg

7.x openid.test OpenIDInvalidIdentifierTransitionTestCase::testStrippedFragmentAccountAutoUpdateSreg()

Test OpenID auto transition with e-mail.

File

drupal-7.x/modules/openid/openid.test, line 633
Tests for openid.module.

Class

OpenIDInvalidIdentifierTransitionTestCase
Test account registration using Simple Registration and Attribute Exchange.

Code

function testStrippedFragmentAccountAutoUpdateSreg() {
  $this->drupalLogin($this->web_user);

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

  // Add invalid identifier to the authmap (identifier has stripped fragment).
  $this->addIdentity($identity_stripped);
  $this->drupalLogout();

  // Test logging in via the login form, provider will respond with full
  // identifier (including fragment) but with different email, so we can't
  // provide auto-update.
  variable_set('openid_test_response', array(
    'openid.claimed_id' => $identity,
    'openid.sreg.nickname' => $this->web_user->name,
    'openid.sreg.email' => $this->web_user->mail));

  $this->submitLoginForm($identity_stripped);

  // Verify user was redirected away from user login to an accessible page.
  $this->assertResponse(200);

  // Verify the message.
  $this->assertRaw(t('New OpenID identifier %identity was added as a replacement for invalid identifier %invalid_identity.', array('%invalid_identity' => $identity_stripped, '%identity' => $identity)), 'Message that OpenID identifier was added automatically was displayed.');
}