function FormsFormCacheTestCase::testCacheForm
Tests storing and retrieving the form from cache.
File
-
modules/
simpletest/ tests/ form.test, line 1465
Class
- FormsFormCacheTestCase
- Test cache_form.
Code
function testCacheForm() {
$form = drupal_get_form('form_test_cache_form');
$form_state = array(
'foo' => 'bar',
'build_info' => array(
'baz',
),
);
form_set_cache($form['#build_id'], $form, $form_state);
$cached_form_state = array();
$cached_form = form_get_cache($form['#build_id'], $cached_form_state);
$this->assertEqual($cached_form['#build_id'], $form['#build_id'], 'Form retrieved from cache_form successfully.');
$this->assertEqual($cached_form_state['foo'], 'bar', 'Data retrieved from cache_form successfully.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.