Skip to content
Snippets Groups Projects
Verified Commit 775c7267 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3462561 by catch, smustgrave: Stop using a data provider in UserPasswordResetTest

(cherry picked from commit a6f5d7d3)
parent dd994edd
No related branches found
No related tags found
No related merge requests found
......@@ -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
*/
public static function languagePrefixTestProvider() {
protected function languagePrefixTestProvider() {
return [
'Test language prefix set as \'\', visiting default with preferred language as en' => [
'setPreferredLangcode' => 'en',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment