function FormCacheTest::testNoCacheToken

Tests the form cache without a logged-in user.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php, line 76
Contains \Drupal\system\Tests\Form\FormCacheTest.

Class

FormCacheTest
Tests form caching.

Namespace

Drupal\system\Tests\Form

Code

function testNoCacheToken() {
  $GLOBALS['user']->uid = 0;
  $this->form_state['example'] = $this
    ->randomName();
  form_set_cache($this->form_build_id, $this->form, $this->form_state);
  $cached_form_state = form_state_defaults();
  $cached_form = form_get_cache($this->form_build_id, $cached_form_state);
  $this
    ->assertEqual($this->form['#property'], $cached_form['#property']);
  $this
    ->assertTrue(empty($cached_form['#cache_token']), 'Form has no cache token');
  $this
    ->assertEqual($this->form_state['example'], $cached_form_state['example']);
}