Skip to content

Commit

Permalink
Fix for issue #680: Add testing for the bug
Browse files Browse the repository at this point in the history
Refactor \FeatureContext::assertBackendLoggedOut to also ensure the
login page displays the login form.

Add a new testing step definition that logs out via the logout url
rather than fast logout.

Add a new test to backend_login.feature to ensure logout via the url is
working correctly.
  • Loading branch information
tame4tex committed Oct 18, 2024
1 parent 302b09c commit 099cc02
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion features/backend_login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ Feature: Backend login/logout
Given I am logged in as a user with the "authenticated user" role
Then I should be logged in on the backend

Scenario: Logout on the backend
Scenario: Logout on the backend via fast logout
Given I am logged in as a user with the "authenticated user" role
And I am logged in on the backend
When I log out
Then I should be logged out on the backend

Scenario: Logout on the backend via url
Given I am logged in as a user with the "authenticated user" role
And I am logged in on the backend
When I log out via the logout url
Then I should be logged out on the backend
14 changes: 14 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ public function assertBackendLoggedOut()
if (!\Drupal::currentUser()->isAnonymous()) {
throw new \LogicException('User is still logged in on the backend.');
}
// Visit login page and ensure login form is present.
$this->getSession()->visit($this->locatePath($this->getDrupalText('login_url')));
$element = $this->getSession()->getPage();
$element->fillField($this->getDrupalText('username_field'), 'foo');
}

/**
* Logs out via the logout url rather than fast logout.
*
* @Then I log out via the logout url
*/
public function logoutViaUrl()
{
$this->logout(false);
}

/**
Expand Down

0 comments on commit 099cc02

Please sign in to comment.