summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/locale/locale.module2
-rw-r--r--modules/path/path.test80
2 files changed, 81 insertions, 1 deletions
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 48a6bfa1c..d92148b93 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -340,7 +340,7 @@ function locale_form_path_admin_form_alter(&$form, &$form_state) {
$form['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
- '#options' => array('' => t('All languages')) + locale_language_list('name'),
+ '#options' => array(LANGUAGE_NONE => t('All languages')) + locale_language_list('name'),
'#default_value' => $form['language']['#value'],
'#weight' => -10,
'#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set for <em>All languages</em>.'),
diff --git a/modules/path/path.test b/modules/path/path.test
index c8d9f1015..77df4a488 100644
--- a/modules/path/path.test
+++ b/modules/path/path.test
@@ -308,3 +308,83 @@ class PathLanguageTestCase extends DrupalWebTestCase {
$this->assertTrue(strpos($url, $edit['path[alias]']), t('URL contains the path alias.'));
}
}
+
+/**
+ * Tests the user interface for creating path aliases, with languages.
+ */
+class PathLanguageUITestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Path aliases with languages',
+ 'description' => 'Confirm that the Path module user interface works with languages.',
+ 'group' => 'Path',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('path', 'locale');
+
+ // Create and login user.
+ $web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages'));
+ $this->drupalLogin($web_user);
+
+ // Enable French language.
+ $edit = array();
+ $edit['langcode'] = 'fr';
+
+ $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
+
+ // Set language negotiation to "Path prefix with fallback".
+ include_once DRUPAL_ROOT . '/includes/locale.inc';
+ variable_set('language_negotiation_' . LANGUAGE_TYPE_CONTENT, locale_language_negotiation_info());
+ variable_set('locale_language_negotiation_url_part', LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX);
+
+ // Force inclusion of language.inc.
+ drupal_language_initialize();
+ }
+
+ /**
+ * Tests that a language-neutral URL alias works.
+ */
+ function testLanguageNeutralURLs() {
+ $name = $this->randomName(8);
+ $edit = array();
+ $edit['source'] = 'admin/config/search/path';
+ $edit['alias'] = $name;
+ $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
+
+ $this->drupalGet($name);
+ $this->assertText(t('Filter aliases'), 'Language-neutral URL alias works');
+ }
+
+ /**
+ * Tests that a default language URL alias works.
+ */
+ function testDefaultLanguageURLs() {
+ $name = $this->randomName(8);
+ $edit = array();
+ $edit['source'] = 'admin/config/search/path';
+ $edit['alias'] = $name;
+ $edit['language'] = 'en';
+ $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
+
+ $this->drupalGet($name);
+ $this->assertText(t('Filter aliases'), 'English URL alias works');
+ }
+
+ /**
+ * Tests that a non-default language URL alias works.
+ */
+ function testNonDefaultURLs() {
+ $name = $this->randomName(8);
+ $edit = array();
+ $edit['source'] = 'admin/config/search/path';
+ $edit['alias'] = $name;
+ $edit['language'] = 'fr';
+ $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
+
+ $this->drupalGet('fr/' . $name);
+ $this->assertText(t('Filter aliases'), 'Foreign URL alias works');
+ }
+
+}