You are here

function MenuRouterTestCase::testAuthUserUserLogin in Drupal 7

Test that an authenticated user hitting 'user/login' gets redirected to 'user' and 'user/register' gets redirected to the user edit page.

File

modules/simpletest/tests/menu.test, line 241
Provides SimpleTests for menu.inc.

Class

MenuRouterTestCase

Code

function testAuthUserUserLogin() {
  $loggedInUser = $this
    ->drupalCreateUser(array());
  $this
    ->drupalLogin($loggedInUser);
  $this
    ->drupalGet('user/login');

  // Check that we got to 'user'.
  $this
    ->assertTrue($this->url == url('user', array(
    'absolute' => TRUE,
  )), "Logged-in user redirected to q=user on accessing q=user/login");

  // user/register should redirect to user/UID/edit.
  $this
    ->drupalGet('user/register');
  $this
    ->assertTrue($this->url == url('user/' . $this->loggedInUser->uid . '/edit', array(
    'absolute' => TRUE,
  )), "Logged-in user redirected to q=user/UID/edit on accessing q=user/register");
}