diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-01 21:18:33 -0800 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-03-01 21:18:33 -0800 |
commit | 50fdcb190e0abe82b6465fe70fb3cc5dccf9345c (patch) | |
tree | 9e6517eff26f07704157830315ff6fb2e547b11b /modules/path | |
parent | 9749406ba02b277b8e30c21b640cbf17cf50b265 (diff) | |
download | brdo-50fdcb190e0abe82b6465fe70fb3cc5dccf9345c.tar.gz brdo-50fdcb190e0abe82b6465fe70fb3cc5dccf9345c.tar.bz2 |
Issue #1393604 by tedbow, Niklas Fiekas: Fixed path_form_element_validate() does not send correct parameter to form_set_error().
Diffstat (limited to 'modules/path')
-rw-r--r-- | modules/path/path.module | 2 | ||||
-rw-r--r-- | modules/path/path.test | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/modules/path/path.module b/modules/path/path.module index e64b26836..86b714d47 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -173,7 +173,7 @@ function path_form_element_validate($element, &$form_state, $complete_form) { $query->addExpression('1'); $query->range(0, 1); if ($query->execute()->fetchField()) { - form_set_error('alias', t('The alias is already in use.')); + form_error($element, t('The alias is already in use.')); } } } diff --git a/modules/path/path.test b/modules/path/path.test index f42ec81be..acd4e20a6 100644 --- a/modules/path/path.test +++ b/modules/path/path.test @@ -162,6 +162,23 @@ class PathTestCase extends DrupalWebTestCase { 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.'); + } } /** |