diff --git a/core/includes/form.inc b/core/includes/form.inc diff --git a/core/modules/simpletest/tests/form.test b/core/modules/simpletest/tests/form.test index 784da88..a0cd54d 100644 --- a/core/modules/simpletest/tests/form.test +++ b/core/modules/simpletest/tests/form.test @@ -5,6 +5,40 @@ * Unit tests for the Drupal Form API. */ +/** + * Test duplicates elemens IDs when form validation fails. + */ +class FormsDuplicateElementIdsTestCase extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Duplicates in DOM when form validation fails', + 'description' => 'Create two form on page and submit one of them.', + 'group' => 'Form API', + ); + } + + function setUp() { + parent::setUp('contact'); + } + + function testFormValidationFails() { + + // Give anonymous user permission to use contact form + user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); + + // Go to page contains contact form + $this->drupalGet('contact'); + + // Submit contact form + $this->drupalPost(NULL, array(), t('Send message')); + + // Check duplicate IDs in DOM + $this->assertNoDuplicateIds('There are no duplicate IDs'); + } + +} + class FormsTestCase extends DrupalWebTestCase { public static function getInfo() {