1 form.test FormsFormStorageTestCase::testForm()

Tests using the form in a usual way.

File

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

Class

FormsFormStorageTestCase
Test the form storage on a multistep form.

Code

function testForm() {
  $this->backdropGet('form_test/form-storage');
  $this->assertText('Form constructions: 1');

  $edit = array('title' => 'new', 'value' => 'value_is_set');

  // Use form rebuilding triggered by a submit button.
  $this->backdropPost(NULL, $edit, 'Continue submit');
  $this->assertText('Form constructions: 2');
  $this->assertText('Form constructions: 3');

  // Reset the form to the values of the storage, using a form rebuild
  // triggered by button of type button.
  $this->backdropPost(NULL, array('title' => 'changed'), 'Reset');
  $this->assertFieldByName('title', 'new', 'Values have been reset.');
  // After rebuilding, the form has been cached.
  $this->assertText('Form constructions: 4');

  $this->backdropPost(NULL, $edit, 'Save');
  $this->assertText('Form constructions: 4');
  $this->assertText('Title: new', 'The form storage has stored the values.');
}