From 70e53b33c1074655f4ee917c0c4f4b1219bb109d Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sat, 2 Jan 2010 23:30:53 +0000 Subject: #370537 by chx, sun, effulgentsia, quicksketch, eaton, Heine, and yched: Allow buttons to only validate sections of forms, e.g. More buttons. (with tests) --- modules/simpletest/tests/form.test | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/simpletest/tests/form.test') 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'); + } } /** -- cgit v1.2.3