Skip to content

Commit 46d89c5

Browse files
authored
Merge branch 'main' into align-drupal-core
2 parents ea6bdec + e02ccef commit 46d89c5

File tree

8 files changed

+53
-9
lines changed

8 files changed

+53
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
9+
## [5.1.0]
10+
### Added
11+
* [#677](https://github.com/jhedstrom/drupalextension/pull/677) - Drupal 11 support
912
## [5.0.0]
1013
### Added
1114
* [#655](https://github.com/jhedstrom/drupalextension/pull/655) Configure Guzzle request options
@@ -148,7 +151,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
148151
* [#437](https://github.com/jhedstrom/drupalextension/pull/437): Radio button selector fix.
149152
* [#439](https://github.com/jhedstrom/drupalextension/pull/439): Symfony 3 compatibility follow-up fix.
150153

151-
[Unreleased]: https://github.com/jhedstrom/drupalextension/compare/v5.0.0...HEAD
154+
[Unreleased]: https://github.com/jhedstrom/drupalextension/compare/v5.1.0...HEAD
155+
[5.1.0]: https://github.com/jhedstrom/drupalextension/compare/v5.0.0...v5.1.0
152156
[5.0.0]: https://github.com/jhedstrom/drupalextension/compare/v5.0.0rc1...v5.0.0
153157
[5.0.0 alpha1]: https://github.com/jhedstrom/drupalextension/compare/v4.2.0...v5.0.0alpha1
154158
[4.2.0]: https://github.com/jhedstrom/drupalextension/compare/v4.1.0...v4.2.0

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ the [Full documentation](https://behat-drupal-extension.readthedocs.org)
3030

3131
1. Install using [Composer](https://getcomposer.org/):
3232

33-
``` bash
33+
```bash
3434
mkdir projectdir
3535
cd projectdir
3636
curl -sS https://getcomposer.org/installer | php
@@ -41,7 +41,7 @@ the [Full documentation](https://behat-drupal-extension.readthedocs.org)
4141
minimal configuration. Many more options are covered in the
4242
[Full documentation](https://behat-drupal-extension.readthedocs.org)
4343

44-
``` yaml
44+
```yaml
4545
default:
4646
suites:
4747
default:
@@ -60,7 +60,7 @@ the [Full documentation](https://behat-drupal-extension.readthedocs.org)
6060
base_url: http://example.org/ # Replace with your site's URL
6161
Drupal\DrupalExtension:
6262
blackbox: ~
63-
```
63+
```
6464

6565
1. In the projectdir, run
6666

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"drupal/drupal-driver": "^2.2.1 || dev-master",
2828
"friends-of-behat/mink-extension": "^2.7.1",
2929
"lullabot/mink-selenium2-driver": "^1.7",
30-
"symfony/http-client": "~4.4 || ^5 || ^6",
30+
"symfony/http-client": "~4.4 || ^5 || ^6" || ^7,
3131
"webflo/drupal-finder": "^1.2"
3232
},
3333
"require-dev": {

features/backend_login.feature

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ Feature: Backend login/logout
88
Given I am logged in as a user with the "authenticated user" role
99
Then I should be logged in on the backend
1010

11-
Scenario: Logout on the backend
11+
Scenario: Logout on the backend via fast logout
1212
Given I am logged in as a user with the "authenticated user" role
1313
And I am logged in on the backend
1414
When I log out
1515
Then I should be logged out on the backend
16+
17+
Scenario: Logout on the backend via url
18+
Given I am logged in as a user with the "authenticated user" role
19+
And I am logged in on the backend
20+
When I log out via the logout url
21+
Then I should be logged out on the backend

features/bootstrap/FeatureContext.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ public function assertBackendLoggedOut()
229229
if (!\Drupal::currentUser()->isAnonymous()) {
230230
throw new \LogicException('User is still logged in on the backend.');
231231
}
232+
// Visit login page and ensure login form is present.
233+
$this->getSession()->visit($this->locatePath($this->getDrupalText('login_url')));
234+
$element = $this->getSession()->getPage();
235+
$element->fillField($this->getDrupalText('username_field'), 'foo');
236+
}
237+
238+
/**
239+
* Logs out via the logout url rather than fast logout.
240+
*
241+
* @Then I log out via the logout url
242+
*/
243+
public function logoutViaUrl()
244+
{
245+
$this->logout(false);
232246
}
233247

234248
/**

src/Drupal/DrupalExtension/Context/RawDrupalContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public function parseEntityFields($entity_type, \stdClass $entity)
422422
if ($this->getDriver()->isField($entity_type, $field_name)) {
423423
// Split up multiple values in multi-value fields.
424424
$values = [];
425-
foreach (str_getcsv($field_value) as $key => $value) {
425+
foreach (str_getcsv($field_value, escape: "\\") as $key => $value) {
426426
$value = trim((string) $value);
427427
$columns = $value;
428428
// Split up field columns if the ' - ' separator is present.

src/Drupal/DrupalExtension/Manager/DrupalAuthenticationManager.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ protected function getLoginSubmitElement(DocumentElement $element)
6161
return $element->findButton($this->getDrupalText('log_in'));
6262
}
6363

64+
/**
65+
* Helper to get the submit element for the logout confirmation form.
66+
*/
67+
protected function getLogoutConfirmSubmitElement(DocumentElement $element)
68+
{
69+
return $element->findButton($this->getDrupalText('log_out'));
70+
}
71+
6472
/**
6573
* {@inheritdoc}
6674
*/
@@ -102,7 +110,13 @@ public function logIn(\stdClass $user)
102110
*/
103111
public function logout()
104112
{
105-
$this->getSession()->visit($this->locatePath($this->getDrupalText('logout_url')));
113+
$session = $this->getSession();
114+
$session->visit($this->locatePath($this->getDrupalText('logout_url')));
115+
// Check to see if the user is on the logout confirm page (10.3+).
116+
if ($session->getCurrentUrl() === $this->locatePath($this->getDrupalText('logout_confirm_url'))) {
117+
$submit = $this->getLogoutConfirmSubmitElement($session->getPage());
118+
$submit->click();
119+
}
106120
$this->userManager->setCurrentUser(false);
107121

108122
// Log the user out on the backend if possible.

src/Drupal/DrupalExtension/ServiceContainer/DrupalExtension.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class DrupalExtension implements ExtensionInterface
3939
*
4040
* @param null|ServiceProcessor $processor
4141
*/
42-
public function __construct(ServiceProcessor $processor = null)
42+
public function __construct(?ServiceProcessor $processor = null)
4343
{
4444
$this->processor = $processor ? : new ServiceProcessor();
4545
}
@@ -131,11 +131,13 @@ public function configure(ArrayNodeDefinition $builder)
131131
'Text strings, such as Log out or the Username field can be altered via behat.yml if they vary from the default values.' . PHP_EOL
132132
. ' login_url: "/user"' . PHP_EOL
133133
. ' logout_url: "/user/logout"' . PHP_EOL
134+
. ' logout_confirm_url: "/user/logout/confirm"' . PHP_EOL
134135
. ' log_out: "Sign out"' . PHP_EOL
135136
. ' log_in: "Sign in"' . PHP_EOL
136137
. ' password_field: "Enter your password"' . PHP_EOL
137138
. ' username_field: "Nickname"'
138139
)->
140+
ignoreExtraKeys(false)->
139141
addDefaultsIfNotSet()->
140142
children()->
141143
scalarNode('login_url')->
@@ -144,6 +146,9 @@ public function configure(ArrayNodeDefinition $builder)
144146
scalarNode('logout_url')->
145147
defaultValue('/user/logout')->
146148
end()->
149+
scalarNode('logout_confirm_url')->
150+
defaultValue('/user/logout/confirm')->
151+
end()->
147152
scalarNode('log_in')->
148153
defaultValue('Log in')->
149154
end()->
@@ -159,6 +164,7 @@ public function configure(ArrayNodeDefinition $builder)
159164
end()->
160165
end()->
161166
arrayNode('selectors')->
167+
ignoreExtraKeys(false)->
162168
addDefaultsIfNotSet()->
163169
children()->
164170
scalarNode('message_selector')->end()->

0 commit comments

Comments
 (0)