Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
b8de1821
Verified
Commit
b8de1821
authored
7 months ago
by
Théodore Biadala
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3462561
by catch, smustgrave: Stop using a data provider in UserPasswordResetTest
(cherry picked from commit
a6f5d7d3
)
parent
ea6a45ed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!11185
Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4
,
!9944
Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline
#238163
passed
7 months ago
Stage: 🪄 Lint
Stage: 🗜️ Test
Pipeline: drupal
#238167
Changes
1
Pipelines
20
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/user/tests/src/Functional/UserPasswordResetTest.php
+24
-23
24 additions, 23 deletions
...dules/user/tests/src/Functional/UserPasswordResetTest.php
with
24 additions
and
23 deletions
core/modules/user/tests/src/Functional/UserPasswordResetTest.php
+
24
−
23
View file @
b8de1821
...
...
@@ -240,10 +240,8 @@ public function testUserPasswordReset(): void {
/**
* Tests password reset functionality when user has set preferred language.
*
* @dataProvider languagePrefixTestProvider
*/
public
function
testUserPasswordResetPreferredLanguage
(
$setPreferredLangcode
,
$activeLangcode
,
$prefix
,
$visitingUrl
,
$expectedResetUrl
,
$unexpectedResetUrl
):
void
{
public
function
testUserPasswordResetPreferredLanguage
():
void
{
// Set two new languages.
ConfigurableLanguage
::
createFromLangcode
(
'fr'
)
->
save
();
ConfigurableLanguage
::
createFromLangcode
(
'zh-hant'
)
->
save
();
...
...
@@ -255,34 +253,37 @@ public function testUserPasswordResetPreferredLanguage($setPreferredLangcode, $a
$config
->
set
(
'url.prefixes'
,
[
'en'
=>
''
,
'fr'
=>
'fr'
,
'zh-hant'
=>
'zh'
])
->
save
();
$this
->
rebuildContainer
();
$this
->
account
->
preferred_langcode
=
$setPreferredLangcode
;
$this
->
account
->
save
();
$this
->
assertSame
(
$setPreferredLangcode
,
$this
->
account
->
getPreferredLangcode
(
FALSE
));
foreach
(
$this
->
languagePrefixTestProvider
()
as
$scenario
)
{
[
$setPreferredLangcode
,
$activeLangcode
,
$prefix
,
$visitingUrl
,
$expectedResetUrl
,
$unexpectedResetUrl
]
=
array_values
(
$scenario
);
$this
->
account
->
preferred_langcode
=
$setPreferredLangcode
;
$this
->
account
->
save
();
$this
->
assertSame
(
$setPreferredLangcode
,
$this
->
account
->
getPreferredLangcode
(
FALSE
));
// Test Default langcode is different from active langcode when visiting different.
if
(
$setPreferredLangcode
!==
'en'
)
{
$this
->
drupalGet
(
$prefix
.
'/user/password'
);
$this
->
assertSame
(
$activeLangcode
,
$this
->
getSession
()
->
getResponseHeader
(
'Content-language'
));
$this
->
assertSame
(
'en'
,
$this
->
languageManager
->
getDefaultLanguage
()
->
getId
());
}
// Test password reset with language prefixes.
$this
->
drupalGet
(
$visitingUrl
);
$edit
=
[
'name'
=>
$this
->
account
->
getAccountName
()];
$this
->
submitForm
(
$edit
,
'Submit'
);
$this
->
assertValidPasswordReset
(
$edit
[
'name'
]);
// Test Default langcode is different from active langcode when visiting different.
if
(
$setPreferredLangcode
!==
'en'
)
{
$this
->
drupalGet
(
$prefix
.
'/user/password'
);
$this
->
assertSame
(
$activeLangcode
,
$this
->
getSession
()
->
getResponseHeader
(
'Content-language'
));
$this
->
assertSame
(
'en'
,
$this
->
languageManager
->
getDefaultLanguage
()
->
getId
());
$resetURL
=
$this
->
getResetURL
();
$this
->
assertStringContainsString
(
$expectedResetUrl
,
$resetURL
);
$this
->
assertStringNotContainsString
(
$unexpectedResetUrl
,
$resetURL
);
}
// Test password reset with language prefixes.
$this
->
drupalGet
(
$visitingUrl
);
$edit
=
[
'name'
=>
$this
->
account
->
getAccountName
()];
$this
->
submitForm
(
$edit
,
'Submit'
);
$this
->
assertValidPasswordReset
(
$edit
[
'name'
]);
$resetURL
=
$this
->
getResetURL
();
$this
->
assertStringContainsString
(
$expectedResetUrl
,
$resetURL
);
$this
->
assertStringNotContainsString
(
$unexpectedResetUrl
,
$resetURL
);
}
/**
*
Data provider
for testUserPasswordResetPreferredLanguage().
*
Provides scenarios
for testUserPasswordResetPreferredLanguage().
*
* @return array
*/
p
ublic
static
function
languagePrefixTestProvider
()
{
p
rotected
function
languagePrefixTestProvider
()
{
return
[
'Test language prefix set as \'\', visiting default with preferred language as en'
=>
[
'setPreferredLangcode'
=>
'en'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment