diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-12-05 14:33:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-12-05 14:33:55 +0000 |
commit | 0014a64d37e42ccc63f0b44a0ce32a06fca67b1d (patch) | |
tree | fb4041a550379b11917bc698d0ca62d440f79d23 /modules/simpletest/tests/form.test | |
parent | 6c37dbae290ac9f9d83770d399d1286bdfd01f99 (diff) | |
download | brdo-0014a64d37e42ccc63f0b44a0ce32a06fca67b1d.tar.gz brdo-0014a64d37e42ccc63f0b44a0ce32a06fca67b1d.tar.bz2 |
- Patch #641356 by fago, sun: cache more of () when form caching is enabled.
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r-- | modules/simpletest/tests/form.test | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index 0f1769d43..78dff3d45 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -597,6 +597,36 @@ class FormsFormStorageTestCase extends DrupalWebTestCase { $this->assertFieldByName('title', 'title_changed', t('The altered form storage value was updated in cache and taken over.')); $this->assertText('Title: title_changed', t('The form storage has stored the values.')); } + + /** + * Tests a form using form state without using 'storage' to pass data from the + * constructor to a submit handler. The data has to persist even when caching + * gets activated, what may happen when a modules alter the form and adds + * #ajax properties. + */ + function testFormStatePersist() { + // Test the form one time with caching activated and one time without. + $run_options = array( + array(), + array('query' => array('cache' => 1)), + ); + foreach($run_options as $options) { + $this->drupalPost('form-test/state-persist', array(), t('Submit'), $options); + // The submit handler outputs the value in $form_state, assert it's there. + $this->assertText('State persisted.'); + + // Test it again, but first trigger a validation error, then test. + $this->drupalPost('form-test/state-persist', array('title' => ''), t('Submit'), $options); + $this->assertText(t('!name field is required.', array('!name' => 'title'))); + // Submit the form again triggering no validation error. + $this->drupalPost(NULL, array('title' => 'foo'), t('Submit'), $options); + $this->assertText('State persisted.'); + + // Now post to the rebuilt form and verify it's still there afterwards. + $this->drupalPost(NULL, array('title' => 'bar'), t('Submit'), $options); + $this->assertText('State persisted.'); + } + } } /** |