summaryrefslogtreecommitdiff
path: root/modules/path/path.test
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-10-13 20:57:19 +0000
committerDries Buytaert <dries@buytaert.net>2008-10-13 20:57:19 +0000
commit75d5f0cd9185e23939da15cc839bedb6362236b0 (patch)
treed1d2c31c507852faca2963d2c5ec885c2fc59b3b /modules/path/path.test
parentf7e61d77e96b1f67b1ea58273a0cfc8020715f65 (diff)
downloadbrdo-75d5f0cd9185e23939da15cc839bedb6362236b0.tar.gz
brdo-75d5f0cd9185e23939da15cc839bedb6362236b0.tar.bz2
- Patch #204106 by catch, Damien Tournoud: added test for translation of path aliases.
Diffstat (limited to 'modules/path/path.test')
-rw-r--r--modules/path/path.test85
1 files changed, 85 insertions, 0 deletions
diff --git a/modules/path/path.test b/modules/path/path.test
index 48ff0eee8..40023996d 100644
--- a/modules/path/path.test
+++ b/modules/path/path.test
@@ -138,3 +138,88 @@ class PathTestCase extends DrupalWebTestCase {
return $node;
}
}
+
+class PathLanguageTestCase extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Path aliases with translated nodes'),
+ 'description' => t('Confirm that paths work with translated nodes'),
+ 'group' => t('Path'),
+ );
+ }
+
+ /**
+ * Create user, setup permissions, log user in, and create a node.
+ */
+ function setUp() {
+ parent::setUp('path', 'locale', 'translation');
+
+ // Create and login user.
+ $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate content', 'access administration pages'));
+ $this->drupalLogin($web_user);
+
+ // Enable French language.
+ $edit = array();
+ $edit['langcode'] = 'fr';
+
+ $this->drupalPost('admin/settings/language/add', $edit, t('Add language'));
+
+ // Set language negotiation to "Path prefix with fallback".
+ variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
+
+ // Force inclusion of language.inc.
+ drupal_init_language();
+ }
+
+ /**
+ * Test alias functionality through the admin interfaces.
+ */
+ function testAliasTranslation() {
+ // Set 'page' content type to enable translation.
+ variable_set('language_content_type_page', 2);
+
+ // Create a page in English.
+ $edit = array();
+ $edit['title'] = $this->randomName();
+ $edit['body'] = $this->randomName();
+ $edit['language'] = 'en';
+ $edit['path'] = $this->randomName();
+
+ $this->drupalPost('node/add/page', $edit, t('Save'));
+
+ // Check to make sure the node was created.
+ $english_node = node_load(array('title' => $edit['title']));
+ $this->assertTrue(($english_node), 'Node found in database.');
+
+ // Confirm that the alias works.
+ $this->drupalGet($edit['path']);
+ $this->assertText($english_node->title, 'Alias works.');
+
+ // Translate the node into French.
+ $this->drupalGet('node/' . $english_node->nid . '/translate');
+ $this->clickLink(t('add translation'));
+ $edit = array();
+ $edit['title'] = $this->randomName();
+ $edit['body'] = $this->randomName();
+ $edit['path'] = $this->randomName();
+ $this->drupalPost(NULL, $edit, t('Save'));
+
+ // Clear the path lookup cache.
+ drupal_lookup_path('wipe');
+
+ // Ensure the node was created.
+ // Check to make sure the node was created.
+ $french_node = node_load(array('title' => $edit['title']));
+ $this->assertTrue(($french_node), 'Node found in database.');
+
+ // Confirm that the alias works.
+ $this->drupalGet('fr/' . $edit['path']);
+ $this->assertText($french_node->title, 'Alias for French translation works.');
+
+ // Confirm that the alias is returned by url().
+ $languages = language_list();
+ $url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->language]));
+ $this->assertTrue(strpos($url, $edit['path']), t('URL contains the path alias.'));
+ }
+}
+