1 form.test FormsFormStorageTestCase::testMutableForm()

Verify that the form build-id remains the same when validation errors occur on a mutable form.

File

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

Class

FormsFormStorageTestCase
Test the form storage on a multistep form.

Code

function testMutableForm() {
  // Request the form with 'cache' query parameter to enable form caching.
  $this->backdropGet('form_test/form-storage', array('query' => array('cache' => 1)));
  $buildIdFields = $this->xpath('//input[@name="form_build_id"]');
  $this->assertEqual(count($buildIdFields), 1, 'One form build id field on the page');
  $buildId = (string) $buildIdFields[0]['value'];

  // Trigger validation error by submitting an empty title.
  $edit = array('title' => '');
  $this->backdropPost(NULL, $edit, 'Continue submit');

  // Verify that the build-id did not change.
  $this->assertFieldByName('form_build_id', $buildId, 'Build id remains the same when form validation fails');
}