function FormsFormStorageTestCase::testMutableForm

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

File

modules/simpletest/tests/form.test, line 1273

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->drupalGet('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->drupalPost(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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.