1 form.test FormsFormCacheTestCase::testCacheForm()

Tests storing and retrieving the form from cache.

File

core/modules/simpletest/tests/form.test, line 1464
Unit tests for the Backdrop Form API.

Class

FormsFormCacheTestCase
Test cache_form.

Code

function testCacheForm() {
  $form = backdrop_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.');
}