public function FormsFormStoragePageCacheTestCase::testRebuildFormStorageOnCachedPage

Build-id is regenerated when rebuilding cached form.

File

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

Class

FormsFormStoragePageCacheTestCase
Test the form storage when page caching for anonymous users is turned on.

Code

public function testRebuildFormStorageOnCachedPage() {
  $this
    ->drupalGet('form_test/form-storage-page-cache');
  $this
    ->assertEqual($this
    ->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
  $this
    ->assertText('No old build id', 'No old build id on the page');
  $build_id_initial = $this
    ->getFormBuildId();

  // Trigger rebuild, should regenerate build id.
  $edit = array(
    'title' => 'something',
  );
  $this
    ->drupalPost(NULL, $edit, 'Rebuild');
  $this
    ->assertText($build_id_initial, 'Initial build id as old build id on the page');
  $build_id_first_rebuild = $this
    ->getFormBuildId();
  $this
    ->assertNotEqual($build_id_initial, $build_id_first_rebuild, 'Build id changes on first rebuild.');

  // Trigger subsequent rebuild, should regenerate the build id again.
  $edit = array(
    'title' => 'something',
  );
  $this
    ->drupalPost(NULL, $edit, 'Rebuild');
  $this
    ->assertText($build_id_first_rebuild, 'First build id as old build id on the page');
  $build_id_second_rebuild = $this
    ->getFormBuildId();
  $this
    ->assertNotEqual($build_id_first_rebuild, $build_id_second_rebuild, 'Build id changes on second rebuild.');
}