function MenuRouterTestCase::testAuthUserUserLogin

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

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");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.