1 form.test public FormsFormStoragePageCacheTestCase::testRebuildFormStorageOnCachedPage()

Build-id is regenerated when rebuilding cached form.

File

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

Class

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

Code

public function testRebuildFormStorageOnCachedPage() {
  $this->backdropGet('form_test/form-storage-page-cache');
  $this->assertEqual($this->backdropGetHeader('X-Backdrop-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->backdropPost(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->backdropPost(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.');
}