diff options
Diffstat (limited to 'modules/path/path.test')
-rw-r--r-- | modules/path/path.test | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/modules/path/path.test b/modules/path/path.test index f42ec81be..f5c303c3a 100644 --- a/modules/path/path.test +++ b/modules/path/path.test @@ -2,9 +2,12 @@ /** * @file - * Tests for path.module. + * Tests for the Path module. */ +/** + * Provides a base class for testing the Path module. + */ class PathTestCase extends DrupalWebTestCase { public static function getInfo() { return array( @@ -23,7 +26,7 @@ class PathTestCase extends DrupalWebTestCase { } /** - * Test the path cache. + * Tests the path cache. */ function testPathCache() { // Create test node. @@ -48,7 +51,7 @@ class PathTestCase extends DrupalWebTestCase { } /** - * Test alias functionality through the admin interfaces. + * Tests alias functionality through the admin interfaces. */ function testAdminAlias() { // Create test node. @@ -107,7 +110,7 @@ class PathTestCase extends DrupalWebTestCase { } /** - * Test alias functionality through the node interfaces. + * Tests alias functionality through the node interfaces. */ function testNodeAlias() { // Create test node. @@ -159,13 +162,39 @@ class PathTestCase extends DrupalWebTestCase { $this->assertResponse(404); } + /** + * Returns the path ID. + * + * @param $alias + * A string containing an aliased path. + * + * @return int + * Integer representing the path ID. + */ function getPID($alias) { return db_query("SELECT pid FROM {url_alias} WHERE alias = :alias", array(':alias' => $alias))->fetchField(); } + + /** + * Tests that duplicate aliases fail validation. + */ + function testDuplicateNodeAlias() { + // Create one node with a random alias. + $node_one = $this->drupalCreateNode(); + $edit = array(); + $edit['path[alias]'] = $this->randomName(); + $this->drupalPost('node/' . $node_one->nid . '/edit', $edit, t('Save')); + + // Now create another node and try to set the same alias. + $node_two = $this->drupalCreateNode(); + $this->drupalPost('node/' . $node_two->nid . '/edit', $edit, t('Save')); + $this->assertText(t('The alias is already in use.')); + $this->assertFieldByXPath("//input[@name='path[alias]' and contains(@class, 'error')]", $edit['path[alias]'], 'Textfield exists and has the error class.'); + } } /** - * Test URL aliases for taxonomy terms. + * Tests URL aliases for taxonomy terms. */ class PathTaxonomyTermTestCase extends DrupalWebTestCase { public static function getInfo() { @@ -185,7 +214,7 @@ class PathTaxonomyTermTestCase extends DrupalWebTestCase { } /** - * Test alias functionality through the admin interfaces. + * Tests alias functionality through the admin interfaces. */ function testTermAlias() { // Create a term in the default 'Tags' vocabulary with URL alias. @@ -228,6 +257,9 @@ class PathTaxonomyTermTestCase extends DrupalWebTestCase { } } +/** + * Tests URL aliases for translated nodes. + */ class PathLanguageTestCase extends DrupalWebTestCase { public static function getInfo() { return array( |