function UserAccountLinksTest::testAnonymousLogout

Same name and namespace in other branches
  1. 10 core/modules/user/tests/src/Functional/UserAccountLinksTest.php \Drupal\Tests\user\Functional\UserAccountLinksTest::testAnonymousLogout()
  2. 11.x core/modules/user/tests/src/Functional/UserAccountLinksTest.php \Drupal\Tests\user\Functional\UserAccountLinksTest::testAnonymousLogout()

Ensures that logout url redirects an anonymous user to the front page.

File

core/modules/user/tests/src/Functional/UserAccountLinksTest.php, line 122

Class

UserAccountLinksTest
Tests user-account links.

Namespace

Drupal\Tests\user\Functional

Code

public function testAnonymousLogout() {
    $this->drupalGet('user/logout');
    $this->assertSession()
        ->addressEquals('/');
    $this->assertSession()
        ->statusCodeEquals(200);
    // The redirection shouldn't affect other pages.
    $this->drupalGet('admin');
    $this->assertSession()
        ->addressEquals('/admin');
    $this->assertSession()
        ->statusCodeEquals(403);
}

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