1 form.test FormsFormStorageTestCase::testMutableForm()

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


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


Test the form storage on a multistep form.


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