function UserAccountLinksTest::testAnonymousLogout

Same name in other branches
  1. 9 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() : void {
    $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.