diff --git a/src/Drupal/DrupalExtension/Context/RawDrupalContext.php b/src/Drupal/DrupalExtension/Context/RawDrupalContext.php index bd84cf33..3d2593e4 100644 --- a/src/Drupal/DrupalExtension/Context/RawDrupalContext.php +++ b/src/Drupal/DrupalExtension/Context/RawDrupalContext.php @@ -266,8 +266,11 @@ public function cleanUsers() } $this->getDriver()->processBatch(); $this->userManager->clearUsers(); - if ($this->loggedIn()) { + // If the authentication manager supports logout, no need to check if the user is logged in. + if ($this->getAuthenticationManager() instanceof FastLogoutInterface) { $this->logout(true); + } elseif ($this->loggedIn()) { + $this->logout(); } } }