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
Comments
Comment #2
jnicola commentedComment #3
jnicola 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!