summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngie Byron2010-03-07 18:52:27 (GMT)
committerAngie Byron2010-03-07 18:52:27 (GMT)
commitc5bfbe7fa6bf237cf956a9367be2aa723bf9bdaf (patch)
treece46bc445518fc98be2b134a7c30ab8ae9c4dcdb
parentd1f26518a39f1148f734bfc199702fbce58f6beb (diff)
#163165 by Kars-T, bibo, martinquested, noahb, dereine, sun: Fixed Multilanguage support for user emails.
-rw-r--r--modules/locale/locale.module3
-rw-r--r--modules/locale/locale.test101
2 files changed, 103 insertions, 1 deletions
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 906aaf4..20e94ff 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -319,6 +319,7 @@ function locale_language_selector_form(&$form, &$form_state, $user) {
'#type' => 'fieldset',
'#title' => t('Language settings'),
'#weight' => 1,
+ '#access' => ($form['#user_category'] == 'account' || ($form['#user_category'] == 'register' && user_access('administer users'))),
);
// Get language negotiation settings.
@@ -381,7 +382,7 @@ function locale_form_alter(&$form, &$form_state, $form_id) {
if (drupal_multilingual()) {
// Display language selector when either creating a user on the admin
// interface or editing a user account.
- if (($form_id == 'user_register_form' && user_access('administer users')) || ($form_id == 'user_profile_form' && $form['#user_category'] == 'account')) {
+ if ($form_id == 'user_register_form' || ($form_id == 'user_profile_form' && $form['#user_category'] == 'account')) {
locale_language_selector_form($form, $form_state, $form['#user']);
}
}
diff --git a/modules/locale/locale.test b/modules/locale/locale.test
index 3b60567..d9c6386 100644
--- a/modules/locale/locale.test
+++ b/modules/locale/locale.test
@@ -1271,6 +1271,107 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
}
/**
+ * Functional test for language handling during user creation.
+ */
+class LocalUserCreationTest extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'User creation',
+ 'description' => 'Tests whether proper language is stored for new users and access to language selector.',
+ 'group' => 'Locale',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('locale');
+ }
+
+ /**
+ * Functional test for language handling during user creation.
+ */
+ function testLocalUserCreation() {
+ // User to add and remove language and create new users.
+ $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'administer users'));
+ $this->drupalLogin($admin_user);
+
+ // Add predefined language.
+ $langcode = 'fr';
+ $edit = array(
+ 'langcode' => 'fr',
+ );
+ $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
+ $this->assertText($langcode, t('Language added successfully.'));
+ $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
+
+ // Set language negotiation.
+ $edit = array(
+ 'language[enabled][locale-url]' => TRUE,
+ );
+ $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+ $this->assertText(t('Language negotiation configuration saved.'), t('Set language negotiation.'));
+
+ // Check if the language selector is available on admin/people/create and
+ // set to the currently active language.
+ $this->drupalGet($langcode . '/admin/people/create');
+ $this->assertFieldChecked("edit-language-$langcode", t('Global language set in the language selector.'));
+
+ // Create a user with the admin/people/create form and check if the correct
+ // language is set.
+ $username = $this->randomName(10);
+ $edit = array(
+ 'name' => $username,
+ 'mail' => $this->randomName(4) . '@example.com',
+ 'pass[pass1]' => $username,
+ 'pass[pass2]' => $username,
+ );
+
+ $this->drupalPost($langcode . '/admin/people/create', $edit, t('Create new account'));
+
+ $user = user_load_by_name($username);
+ $this->assertEqual($user->language, $langcode, t('New user has correct language set.'));
+
+ // Register a new user and check if the language selector is hidden.
+ $this->drupalLogout();
+
+ $this->drupalGet($langcode . '/user/register');
+ $this->assertNoFieldByName('language[fr]', t('Language selector is not accessible.'));
+
+ $username = $this->randomName(10);
+ $edit = array(
+ 'name' => $username,
+ 'mail' => $this->randomName(4) . '@example.com',
+ );
+
+ $this->drupalPost($langcode . '/user/register', $edit, t('Create new account'));
+
+ $user = user_load_by_name($username);
+ $this->assertEqual($user->language, $langcode, t('New user has correct language set.'));
+
+ // Test if the admin can use the language selector and if the
+ // correct language is was saved.
+ $user_edit = $langcode . '/user/' . $user->uid . '/edit';
+
+ $this->drupalLogin($admin_user);
+ $this->drupalGet($user_edit);
+ $this->assertFieldChecked("edit-language-$langcode", t('Language selector is accessible and correct language is selected.'));
+
+ // Set pass_raw so we can login the new user.
+ $user->pass_raw = $this->randomName(10);
+ $edit = array(
+ 'pass[pass1]' => $user->pass_raw,
+ 'pass[pass2]' => $user->pass_raw,
+ );
+
+ $this->drupalPost($user_edit, $edit, t('Save'));
+
+ $this->drupalLogin($user);
+ $this->drupalGet($user_edit);
+ $this->assertFieldChecked("edit-language-$langcode", t('Language selector is accessible and correct language is selected.'));
+ }
+}
+
+/**
* Functional tests for configuring a different path alias per language.
*/
class LocalePathFunctionalTest extends DrupalWebTestCase {