function UiHelperTrait::drupalLogout

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()
  2. 8.9.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()
  3. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()

Logs a user out of the Mink controlled browser and confirms.

Confirms logout by checking the login page.

162 calls to UiHelperTrait::drupalLogout()
AccessDeniedTest::testAccessDenied in core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
AccessRoleTest::testAccessRole in core/modules/user/tests/src/Functional/Views/AccessRoleTest.php
Tests role access plugin.
AlertsJsonFeedTest::testAnnounceFeedUpdatedAndRemoved in core/modules/announcements_feed/tests/src/FunctionalJavascript/AlertsJsonFeedTest.php
Check the status of the announcements when the feed is updated and removed.
AnnounceBlockTest::testAnnounceWithoutPermission in core/modules/announcements_feed/tests/src/FunctionalJavascript/AnnounceBlockTest.php
Testing announce feed block visibility.
BigPipeTest::testNoJsDetection in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe's no-JS detection.

... See full list

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 178

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function drupalLogout() {
    // Make a request to the logout page, and redirect to the user page, the
    // idea being if you were properly logged out you should be seeing a login
    // screen.
    $assert_session = $this->assertSession();
    $destination = Url::fromRoute('user.page')->toString();
    $this->drupalGet(Url::fromRoute('user.logout.confirm', options: [
        'query' => [
            'destination' => $destination,
        ],
    ]));
    // Target the submit button using the name rather than the value to work
    // regardless of the user interface language.
    $this->submitForm([], 'op', 'user-logout-confirm');
    $assert_session->fieldExists('name');
    $assert_session->fieldExists('pass');
    $this->drupalResetSession();
}

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