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
CommentFileSizeAuthor
#2 Add-simple-logout-2949532-1.patch551 bytesjnicola
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jnicola created an issue. See original summary.

jnicola’s picture

jnicola’s picture

Issue summary: View changes
jhedstrom’s picture

Thanks 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).

jhedstrom’s picture

Status: Active » Fixed

Thanks for the PR!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.