summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/form.test
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-02 23:30:53 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-02 23:30:53 +0000
commit70e53b33c1074655f4ee917c0c4f4b1219bb109d (patch)
tree7033541b9bc09dfc85aa69be2b57a1f8c8fa9b85 /modules/simpletest/tests/form.test
parentd4f4d3c32e2b7028527b13fc3d63d84576562590 (diff)
downloadbrdo-70e53b33c1074655f4ee917c0c4f4b1219bb109d.tar.gz
brdo-70e53b33c1074655f4ee917c0c4f4b1219bb109d.tar.bz2
#370537 by chx, sun, effulgentsia, quicksketch, eaton, Heine, and yched: Allow buttons to only validate sections of forms, e.g. More buttons. (with tests)
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r--modules/simpletest/tests/form.test21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index ba6a5d622..108391777 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -231,6 +231,27 @@ class FormValidationTestCase extends DrupalWebTestCase {
$this->assertNoFieldByName('name', t('Form element was hidden.'));
$this->assertText('Name value: element_validate_access', t('Value for inaccessible form element exists.'));
}
+
+ /**
+ * Tests partial form validation through #limit_validation_errors.
+ */
+ function testValidateLimitErrors() {
+ $edit = array('test' => 'invalid');
+ $path = 'form-test/limit-validation-errors';
+
+ // Submit the form by pressing the button with #limit_validation_errors and
+ // ensure that the title field is not validated, but the #element_validate
+ // handler for the 'test' field is triggered.
+ $this->drupalPost($path, $edit, t('Partial validate'));
+ $this->assertNoText(t('!name field is required.', array('!name' => 'Title')));
+ $this->assertText('Test element is invalid');
+
+ // Now test full form validation and ensure that the #element_validate
+ // handler is still triggered.
+ $this->drupalPost($path, $edit, t('Full validate'));
+ $this->assertText(t('!name field is required.', array('!name' => 'Title')));
+ $this->assertText('Test element is invalid');
+ }
}
/**