Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The following code can be used to ensure that the user is logged out.
/**
* @Given I am an anonymous user
* @Given I am not logged in
*/
public function assertAnonymousUser() {
// Verify the user is logged out.
if ($this->loggedIn()) {
$this->logout();
}
}
This however reads miserably when you want to just logout. I propose adding "@Then I log out" as it will read better, like this:
Scenario: One role can do something, another can do something with that something
Given I am logged in as a user with the "whatever" role
# Do stuff you want to check another role can interact with
Then I log out
Then I am logged in as a user with the "other" role
# Check you can interact with the previously done work
Comment | File | Size | Author |
---|---|---|---|
#2 | Add-simple-logout-2949532-1.patch | 551 bytes | jnicola |
Comments
Comment #2
jnicola CreditAttribution: jnicola at Oregon Health & Science University (OHSU) commentedComment #3
jnicola CreditAttribution: jnicola at Oregon Health & Science University (OHSU) commentedComment #4
jhedstromThanks for the patch @jnicola! Could you open a PR over at https://github.com/jhedstrom/drupalextension instead? That's where the primary development for this library is happening (for testing purposes primarily).
Comment #5
jhedstromThanks for the PR!