You are here

function FormsFormCacheTestCase::testCacheForm in Drupal 7

Tests storing and retrieving the form from cache.

File

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

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.');
}